diff --git a/app/app/controllers/display/company/review.js b/app/app/controllers/display/company/review.js index 3759de5..48d95ae 100644 --- a/app/app/controllers/display/company/review.js +++ b/app/app/controllers/display/company/review.js @@ -1,9 +1,31 @@ import Controller from 'cuf/controllers/display/company'; import { computed } from '@ember/object'; +import { inject } from '@ember/service'; + +import mutation from 'cuf/gql/mutations/complete'; export default Controller.extend({ - options: { toolbarButtons: [] }, + apollo: inject(), body: computed('model.submission.payload.body', function() { return `
${this.get('model.submission.payload.body')}
`; }), + init() { + this._super(...arguments); + this.set('options', { + toolbarButtons: [] + }); + }, + actions: { + async done() { + try { + const id = this.get('model.submission.id'); + await this.get('apollo').mutate({ mutation, variables: { id } }); + this.get('notify').info('Marked as done!'); + this.set('model.submission.reviewed', true); + } catch (e) { + console.error(e); // eslint-disable-line no-console + this.get('notify').alert('Something went wrong -- please try again!', { closeAfter: null }); + } + }, + }, }); diff --git a/app/app/gql/mutations/complete.graphql b/app/app/gql/mutations/complete.graphql new file mode 100644 index 0000000..f02d47a --- /dev/null +++ b/app/app/gql/mutations/complete.graphql @@ -0,0 +1,7 @@ +mutation Complete($id: String!) { + complete(id: $id) { + result { + ok + } + } +} diff --git a/app/app/styles/app.scss b/app/app/styles/app.scss index aedac15..4a21d6b 100644 --- a/app/app/styles/app.scss +++ b/app/app/styles/app.scss @@ -43,3 +43,9 @@ body.transitioning { padding: 1em; min-height: 8em; } + +.field-modified { + background-color: rgba(24, 188, 156, 0.1) !important; + border: 1px solid rgb(24, 188, 156); + border-right: none; +} diff --git a/app/app/templates/display/company/review.hbs b/app/app/templates/display/company/review.hbs index ceff3a8..2aa03ea 100644 --- a/app/app/templates/display/company/review.hbs +++ b/app/app/templates/display/company/review.hbs @@ -6,7 +6,15 @@

When you are finished making changes, click the "Done" button.

- + {{#if model.submission.reviewed}} + + {{else}} + + {{/if}}

diff --git a/app/app/templates/display/company/review/fields.hbs b/app/app/templates/display/company/review/fields.hbs index 4fa4862..4d2750a 100644 --- a/app/app/templates/display/company/review/fields.hbs +++ b/app/app/templates/display/company/review/fields.hbs @@ -6,11 +6,11 @@
{{#if (eq field.type "long")}} -
+
{{ froala-editor content=body options=options }}
{{else}} -
+
{{ get model.submission.payload field.key }}
{{/if}} diff --git a/graph/src/definitions/index.js b/graph/src/definitions/index.js index a3acf57..b5feeed 100644 --- a/graph/src/definitions/index.js +++ b/graph/src/definitions/index.js @@ -13,10 +13,18 @@ module.exports = gql` type Mutation { company(input: CompanyUpdateInput!): CompanyUpdateSubmission! - complete(id: String!): String! + complete(id: String!): MongoUpdate! singleUpload(file: Upload!): String! } + type MongoUpdate { + result: MongoUpdateStatus + } + + type MongoUpdateStatus { + ok: Int! + } + enum CompanyTypes { Company Agency diff --git a/graph/src/mongodb.js b/graph/src/mongodb.js index 9773b26..c7c4edd 100644 --- a/graph/src/mongodb.js +++ b/graph/src/mongodb.js @@ -12,5 +12,5 @@ module.exports = { connect: () => promise, retrieve: id => client.db().collection('submission').findOne({ _id: new ObjectId(id) }), insert: payload => client.db().collection('submission').insertOne(payload), - complete: id => client.db().collection('submission').updateOne({ _id: id }, { $set: { reviewed: true } }), + complete: id => client.db().collection('submission').updateOne({ _id: new ObjectId(id) }, { $set: { reviewed: true } }), };