Skip to content

Commit

Permalink
make done work
Browse files Browse the repository at this point in the history
  • Loading branch information
solocommand committed Oct 18, 2018
1 parent 344326d commit 4ee667b
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 6 deletions.
24 changes: 23 additions & 1 deletion app/app/controllers/display/company/review.js
Original file line number Diff line number Diff line change
@@ -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 `<div contenteditable=false>${this.get('model.submission.payload.body')}</div>`;
}),
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 });
}
},
},
});
7 changes: 7 additions & 0 deletions app/app/gql/mutations/complete.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mutation Complete($id: String!) {
complete(id: $id) {
result {
ok
}
}
}
6 changes: 6 additions & 0 deletions app/app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
10 changes: 9 additions & 1 deletion app/app/templates/display/company/review.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
<p>When you are finished making changes, click the "Done" button.</p>
</div>
<div class="col-12 col-md-4 col-lg-3 col-xl-2">
<button class="btn btn-block btn-success">{{entypo-icon "save"}} Done</button>
{{#if model.submission.reviewed}}
<button class="btn btn-block btn-outline-success disabled">
{{entypo-icon "check"}} <span class="d-none d-md-inline">Done!</span>
</button>
{{else}}
<button class="btn btn-block btn-primary" {{ action "done" }}>
{{entypo-icon "check"}} <span class="d-none d-md-inline">Mark as done</span>
</button>
{{/if}}
</div>
</div>
<hr>
Expand Down
4 changes: 2 additions & 2 deletions app/app/templates/display/company/review/fields.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<label for="{{ field.key }}-input">{{ field.label }}</label>
<div class="input-group">
{{#if (eq field.type "long")}}
<div class="form-control {{ if (eq (get model.company field.key) (get model.submission.payload field.key)) "text-muted" "border-success" }}" style="height: inherit;">
<div class="form-control {{ if (eq (get model.company field.key) (get model.submission.payload field.key)) "text-muted" "field-modified" }}" style="height: inherit;">
{{ froala-editor content=body options=options }}
</div>
{{else}}
<div readonly class="form-control form-control-plaintext {{ if (eq (get model.company field.key) (get model.submission.payload field.key)) "text-muted" "border-success" }}">
<div readonly class="form-control form-control-plaintext {{ if (eq (get model.company field.key) (get model.submission.payload field.key)) "text-muted" "field-modified" }}">
{{ get model.submission.payload field.key }}
</div>
{{/if}}
Expand Down
10 changes: 9 additions & 1 deletion graph/src/definitions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion graph/src/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }),
};

0 comments on commit 4ee667b

Please sign in to comment.