Skip to content

Commit

Permalink
Merge pull request documize#377 from Ma27/preview-button-toggle
Browse files Browse the repository at this point in the history
gui/editors: toggle Preview/Edit button
  • Loading branch information
HarveyKandola authored Nov 12, 2020
2 parents a0a1661 + 9ed8f79 commit 9724131
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ version: "3"

services:
db:
image: postgres:latest
image: postgres:12
restart: always
ports:
- 5432:5432
Expand Down
6 changes: 6 additions & 0 deletions gui/app/components/section/base-editor-inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default Component.extend(Modals, Notifier, {
return `page-editor-${page.id}`;
}),
previewText: 'Preview',
previewIcon: computed('previewIcon', function () {
let constants = this.get('constants');
return constants.Icon.Preview;
}),
pageTitle: '',

didReceiveAttrs() {
Expand Down Expand Up @@ -102,8 +106,10 @@ export default Component.extend(Modals, Notifier, {
},

onPreview() {
let constants = this.get('constants');
let pt = this.get('previewText');
this.set('previewText', pt === 'Preview' ? 'Edit Mode' : 'Preview');
this.set('previewIcon', pt === 'Preview' ? constants.Icon.Edit : constants.Icon.Preview);
return this.get('onPreview')();
},

Expand Down
1 change: 1 addition & 0 deletions gui/app/components/ui/ui-toolbar-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default Component.extend({
click(e) {
if (!_.isUndefined(this.onClick)) {
this.onClick(e);
this.notifyPropertyChange('calcClass');
return;
}

Expand Down
4 changes: 2 additions & 2 deletions gui/app/templates/components/section/base-editor-inline.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
tooltip="Insert Link" onClick=(action "onShowLinkModal")}}
{{/if}}
{{#if previewButton}}
{{ui/ui-toolbar-icon icon=constants.Icon.Preview color=constants.Color.Gray
tooltip="Preview changes" onClick=(action "onPreview")}}
{{ui/ui-toolbar-icon icon=previewIcon color=constants.Color.Gray
tooltip=previewText onClick=(action "onPreview")}}
{{/if}}
{{ui/ui-toolbar-icon icon=constants.Icon.Tick color=constants.Color.Green tooltip="Save changes" onClick=(action "onAction")}}
{{ui/ui-toolbar-icon icon=constants.Icon.Cross color=constants.Color.Red tooltip="Cancel editing" onClick=(action "onCancel")}}
Expand Down

0 comments on commit 9724131

Please sign in to comment.