story-content: Added edit story modal, added toggle component.
This commit is contained in:
+35
-2
@@ -10,17 +10,21 @@ class Story {
|
||||
* @param {string} name
|
||||
* @param {string} author
|
||||
* @param {"Info"|"News"|"Document"|"Background"|"Story"} category Story's category
|
||||
* @param {boolean} listed
|
||||
* @param {boolean} open
|
||||
* @param {string} createdDate
|
||||
* @param {string} updatedDate
|
||||
* @param {string} fictionalDate
|
||||
* @param {{kind:string, name:string}[]} tags
|
||||
* @param {Chapter[]} chapters
|
||||
*/
|
||||
constructor(id, name, author, category, createdDate, updatedDate, fictionalDate, tags, chapters) {
|
||||
constructor(id, name, author, category, listed, open, createdDate, updatedDate, fictionalDate, tags, chapters) {
|
||||
this.id = id
|
||||
this.name = name
|
||||
this.author = author
|
||||
this.category = category
|
||||
this.listed = listed
|
||||
this.open = open
|
||||
this.createdDate = new Date(createdDate)
|
||||
this.updatedDate = new Date(updatedDate)
|
||||
this.fictionalDate = fictionalDate != null ? new Date(fictionalDate) : null
|
||||
@@ -69,13 +73,15 @@ const storyApi = {
|
||||
kind
|
||||
name
|
||||
}
|
||||
listed
|
||||
open
|
||||
createdDate
|
||||
fictionalDate
|
||||
updatedDate
|
||||
}
|
||||
}
|
||||
`, {filter}).then(({stories}) => {
|
||||
return stories.map(d => new Story(d.id, d.name, d.author, d.category, d.createdDate, d.updatedDate, d.fictionalDate, d.tags))
|
||||
return stories.map(d => new Story(d.id, d.name, d.author, d.category, d.listed, d.open, d.createdDate, d.updatedDate, d.fictionalDate, d.tags))
|
||||
})
|
||||
},
|
||||
|
||||
@@ -95,6 +101,8 @@ const storyApi = {
|
||||
kind
|
||||
name
|
||||
}
|
||||
listed
|
||||
open
|
||||
createdDate
|
||||
fictionalDate
|
||||
updatedDate
|
||||
@@ -112,6 +120,7 @@ const storyApi = {
|
||||
`, {id}).then(({story}) => {
|
||||
return new Story(
|
||||
story.id, story.name, story.author, story.category,
|
||||
story.listed, story.open,
|
||||
story.createdDate, story.updatedDate, story.fictionalDate,
|
||||
story.tags, story.chapters
|
||||
)
|
||||
@@ -185,6 +194,30 @@ const storyApi = {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Call `editStory(input)` mutation, returns the changable fields.
|
||||
*
|
||||
* @param {{id:string, name:string, category:string, author:string, open:boolean, listed:boolean, fictionalDate:Date, clearFictionalDate:boolean}} input
|
||||
* @returns {Promise<{id:string, name:string, category:string, author:string, open:boolean, listed:boolean, fictionalDate:Date}>}
|
||||
*/
|
||||
edit(input) {
|
||||
return query(`
|
||||
mutation EditStory($input: StoryEditInput!) {
|
||||
editStory(input:$input) {
|
||||
id
|
||||
name
|
||||
category
|
||||
author
|
||||
open
|
||||
listed
|
||||
fictionalDate
|
||||
}
|
||||
}
|
||||
`, {input}, {permissions: ["member", "story.edit"]}).then(({editStory}) => {
|
||||
return editStory
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Call `removeStory(input)` mutation, returns the id.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user