Add error message and disabling of preview button
This commit is contained in:
@@ -61,10 +61,14 @@ module.exports = class MarkdownImage extends BaseModel
|
||||
|
||||
return @_mimeType
|
||||
|
||||
isValid: ->
|
||||
return @status in [ Status.creatable, Status.unchanged, Status.updateable ]
|
||||
|
||||
Object.defineProperties @prototype,
|
||||
fullPath: {get:@prototype.getFullPath}
|
||||
imageUrl: {get:@prototype.getImageUrl}
|
||||
mimeType: {get:@prototype.getMimeType}
|
||||
valid: {get:@prototype.isValid}
|
||||
|
||||
# BaseModel Overrides ##########################################################################
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ module.exports = class MarkdownImageList extends BaseModel
|
||||
image.fetch()
|
||||
|
||||
reset: ->
|
||||
for fileName, image of @_images
|
||||
@stopListening image
|
||||
|
||||
@_images = {}
|
||||
@_analyzeMarkdownText()
|
||||
|
||||
@@ -54,13 +57,19 @@ module.exports = class MarkdownImageList extends BaseModel
|
||||
|
||||
return result
|
||||
|
||||
isValid: ->
|
||||
for fileName, image of @_images
|
||||
return false unless image.valid
|
||||
return true
|
||||
|
||||
Object.defineProperties @prototype,
|
||||
all: {get:@prototype.getAll}
|
||||
valid: {get:@prototype.isValid}
|
||||
|
||||
# Private Methods ##############################################################################
|
||||
|
||||
_analyzeMarkdownText: ->
|
||||
regex = /\!\[([^\]]*)\]\(([^\)]*)\)/g
|
||||
regex = /\!\[([^\]\n]*)\]\(([^\)\n]*)\)/g
|
||||
newImages = {}
|
||||
changed = false
|
||||
|
||||
@@ -73,6 +82,7 @@ module.exports = class MarkdownImageList extends BaseModel
|
||||
image = @_images[fileName]
|
||||
if not image?
|
||||
image = new MarkdownImage {fileName:fileName, path:@imageBase}, {client:@client}
|
||||
@listenTo image, Event.change, => @trigger Event.change, this
|
||||
@trigger Event.add, this, image
|
||||
changed = true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user