Allow submitting changes for item desc. to GitHub
This commit is contained in:
@@ -145,14 +145,26 @@ module.exports = class ItemPageController extends PageController
|
||||
if not @model.item?
|
||||
return w.reject new Error 'must have an item'
|
||||
|
||||
@client.fetchFile file:GitHub.file.itemDescription modSlug:@_itemSlug.mod, itemSlug:@_itemSlug.item
|
||||
.then (fileRecord)=>
|
||||
@_editingFile = fileRecord
|
||||
@model.item.parse fileRecord.content
|
||||
@client.fetchFile path:GitHub.file.itemDescription modSlug:@_itemSlug.mod, itemSlug:@_itemSlug.item
|
||||
.then (response)=>
|
||||
@_editingFile = response.json.data
|
||||
@model.item.parse @_editingFile.content
|
||||
@_descriptionController.model = @model.item.description
|
||||
|
||||
_endEditingDescription: ->
|
||||
return w(true).delay(1000)
|
||||
oldDescription = @model.item.description
|
||||
@model.item.description = @_descriptionController.model
|
||||
|
||||
args =
|
||||
content: @model.item.unparse()
|
||||
message: "User-submitted text for #{@model.item.name}"
|
||||
path: GitHub.file.itemDescription modSlug:@_itemSlug.mod, itemSlug:@_itemSlug.item
|
||||
sha: @_editingFile.sha
|
||||
|
||||
@client.updateFile args
|
||||
.catch (e)=>
|
||||
@model.item.description = oldDescription
|
||||
throw e
|
||||
|
||||
_refreshByline: ->
|
||||
mod = @model.item?.modVersion?.mod
|
||||
|
||||
@@ -79,7 +79,6 @@ module.exports = class MarkdownSectionController extends BaseController
|
||||
onSaveClicked: (event)->
|
||||
event.preventDefault()
|
||||
|
||||
nextState = State.viewing
|
||||
@state = State.waiting
|
||||
@_endEditing()
|
||||
.then =>
|
||||
@@ -87,10 +86,9 @@ module.exports = class MarkdownSectionController extends BaseController
|
||||
.catch (e)=>
|
||||
logger.error "failed to end editing: #{e}"
|
||||
@state = State.appologizing
|
||||
nextState = State.editing
|
||||
.delay @confirmDuration
|
||||
.then =>
|
||||
@state = nextState
|
||||
@state = State.viewing
|
||||
|
||||
onTextChanged: (event)->
|
||||
event.preventDefault()
|
||||
|
||||
Reference in New Issue
Block a user