logs-content: Added edit log form.
This commit is contained in:
+91
-3
@@ -35,7 +35,7 @@ class Log {
|
||||
}
|
||||
}
|
||||
|
||||
const logsApi = {
|
||||
class LogAPI {
|
||||
find(id) {
|
||||
return query(`
|
||||
query FindLog($id: String!) {
|
||||
@@ -75,7 +75,95 @@ const logsApi = {
|
||||
`, {id}).then(({log}) => {
|
||||
return Log.fromData(log)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Call `addLog(input)` mutation, returns a Log
|
||||
*
|
||||
* @param {{time:Date, channel:string, title:string, eventName:string, description:string, open:boolean}} input
|
||||
* @returns {Promise<Log>}
|
||||
*/
|
||||
add(input) {
|
||||
return query(`
|
||||
mutation FindLog($input: LogAddInput!) {
|
||||
log(input: $input) {
|
||||
id
|
||||
shortId
|
||||
date
|
||||
title
|
||||
eventName
|
||||
description
|
||||
open
|
||||
channel {
|
||||
name
|
||||
logged
|
||||
hub
|
||||
eventName
|
||||
locationName
|
||||
}
|
||||
characters {
|
||||
id
|
||||
nicks
|
||||
author
|
||||
name
|
||||
shortName
|
||||
description
|
||||
}
|
||||
posts {
|
||||
id
|
||||
position
|
||||
time
|
||||
kind
|
||||
nick
|
||||
text
|
||||
}
|
||||
}
|
||||
}
|
||||
`, {input}, {permissions: ["log.add "]}).then(({addLog}) => {
|
||||
return Log.fromData(addLog)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Call `editLog(input)` mutation, returns the id and all editable fields.
|
||||
*
|
||||
* @param {{id:string, title:string, eventName:string, description:string, open:boolean}} input
|
||||
* @returns {Promise<{id:string, title:string, eventName:string, description:string, open:boolean}>}
|
||||
*/
|
||||
edit(input) {
|
||||
return query(`
|
||||
mutation EditLog($input: LogEditInput!) {
|
||||
editLog(input: $input) {
|
||||
id
|
||||
title
|
||||
eventName
|
||||
description
|
||||
open
|
||||
}
|
||||
}
|
||||
`, {input}, {permissions: ["log.edit"]}).then(({editLog}) => {
|
||||
return editLog
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call `removeLog(input)` mutation, returns the id
|
||||
*
|
||||
* @param {{id:string}} input
|
||||
* @returns {Promise<{id:string}>}
|
||||
*/
|
||||
remove(input) {
|
||||
return query(`
|
||||
mutation RemoveLog($input: LogRemoveInput!) {
|
||||
removeLog(input: $input) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`, {input}, {permissions: ["log.remove"]}).then(({editLog}) => {
|
||||
return editLog
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { Log, logsApi }
|
||||
module.exports = { Log, logsApi: new LogAPI }
|
||||
@@ -14,14 +14,14 @@ class LogHeader {
|
||||
* @param {boolean} open
|
||||
* @param {{id:string,name:string,shortName:string,author:string}[]} characters
|
||||
*/
|
||||
constructor(id, shortId, date, channelName, title, description, event, open, characters) {
|
||||
constructor(id, shortId, date, channelName, title, description, eventName, open, characters) {
|
||||
this.id = id
|
||||
this.shortId = shortId
|
||||
this.date = new Date(date)
|
||||
this.channelName = channelName
|
||||
this.title = title || null
|
||||
this.description = description || null
|
||||
this.event = event || null
|
||||
this.eventName = eventName || null
|
||||
this.open = open
|
||||
this.characters = characters.map(ch => new LogHeaderCharacter(ch.id, ch.name, ch.shortName, ch.author))
|
||||
}
|
||||
@@ -76,7 +76,7 @@ const logHeaderApi = {
|
||||
}
|
||||
}
|
||||
`, {filter}).then(({headers}) => {
|
||||
return headers.map(h => new LogHeader(h.id, h.shortId, h.date, h.channelName, h.title, h.description, h.event, h.open, h.characters))
|
||||
return headers.map(h => new LogHeader(h.id, h.shortId, h.date, h.channelName, h.title, h.description, h.eventName, h.open, h.characters))
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user