|
@@ -195,6 +195,45 @@ class HtmlDocument extends React.Component {
|
195
|
195
|
})
|
196
|
196
|
}
|
197
|
197
|
|
|
198
|
+ handleChangeStatus = async newStatus => {
|
|
199
|
+ const { config, content } = this.state
|
|
200
|
+
|
|
201
|
+ const fetchResultSaveEditStatus = await fetch(`${config.apiUrl}/workspaces/${content.workspace_id}/html-documents/${content.content_id}/status`, {
|
|
202
|
+ ...FETCH_CONFIG,
|
|
203
|
+ method: 'PUT',
|
|
204
|
+ body: JSON.stringify({
|
|
205
|
+ status: newStatus
|
|
206
|
+ })
|
|
207
|
+ })
|
|
208
|
+
|
|
209
|
+ handleFetchResult(fetchResultSaveEditStatus)
|
|
210
|
+ .then(resSave => {
|
|
211
|
+ if (resSave.status !== 204) { // 204 no content so dont take status from resSave.apiResponse.status
|
|
212
|
+ console.warn('Error saving html-document comment. Result:', resSave, 'content:', content, 'config:', config)
|
|
213
|
+ } else {
|
|
214
|
+ this.loadContent()
|
|
215
|
+ }
|
|
216
|
+ })
|
|
217
|
+ }
|
|
218
|
+
|
|
219
|
+ handleClickArchive = async () => {
|
|
220
|
+ console.log('archive')
|
|
221
|
+ // const { config, content } = this.state
|
|
222
|
+ //
|
|
223
|
+ // const fetchResultArchive = await fetch(`${config.apiUrl}/workspaces/${content.workspace_id}/contents/${content.content_id}/archive`, {
|
|
224
|
+ // ...FETCH_CONFIG,
|
|
225
|
+ // method: 'PUT'
|
|
226
|
+ // })
|
|
227
|
+ }
|
|
228
|
+ handleClickDelete = async () => {
|
|
229
|
+ console.log('delete')
|
|
230
|
+ // const { config, content } = this.state
|
|
231
|
+ // const fetchResultDelete = await fetch(`${config.apiUrl}/workspaces/${content.workspace_id}/contents/${content.content_id}/delete`, {
|
|
232
|
+ // ...FETCH_CONFIG,
|
|
233
|
+ // method: 'PUT'
|
|
234
|
+ // })
|
|
235
|
+ }
|
|
236
|
+
|
198
|
237
|
render () {
|
199
|
238
|
const { isVisible, loggedUser, content, timeline, newComment, config } = this.state
|
200
|
239
|
|
|
@@ -212,7 +251,12 @@ class HtmlDocument extends React.Component {
|
212
|
251
|
|
213
|
252
|
<PopinFixedOption
|
214
|
253
|
customClass={`${config.slug}`}
|
|
254
|
+ availableStatus={config.availableStatuses}
|
215
|
255
|
onClickNewVersionBtn={this.handleClickNewVersion}
|
|
256
|
+ onChangeStatus={this.handleChangeStatus}
|
|
257
|
+ selectedStatus={config.availableStatuses.find(s => s.slug === content.status)} // peut être vide avant que api reponde
|
|
258
|
+ onClickArchive={this.handleClickArchive}
|
|
259
|
+ onClickDelete={this.handleClickDelete}
|
216
|
260
|
i18n={i18n}
|
217
|
261
|
/>
|
218
|
262
|
|