From b495041222085924ecf2fd954408448e0e3ddaa3 Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Fri, 21 Dec 2018 17:39:09 +0000 Subject: [PATCH] Hanel empty state for document meta fields --- gui/app/components/document/document-meta.js | 8 +- gui/app/components/document/zdocument-meta.js | 156 ------------------ gui/app/constants/constants.js | 1 + gui/app/styles/core/view/document/meta.scss | 14 ++ .../components/document/document-meta.hbs | 10 ++ .../components/document/zdocument-meta.hbs | 13 -- 6 files changed, 32 insertions(+), 170 deletions(-) delete mode 100644 gui/app/components/document/zdocument-meta.js delete mode 100644 gui/app/templates/components/document/zdocument-meta.hbs diff --git a/gui/app/components/document/document-meta.js b/gui/app/components/document/document-meta.js index bde4f91c..9400d77c 100644 --- a/gui/app/components/document/document-meta.js +++ b/gui/app/components/document/document-meta.js @@ -10,6 +10,7 @@ // https://documize.com import { A } from '@ember/array'; +import { computed } from '@ember/object'; import { inject as service } from '@ember/service'; import Modals from '../../mixins/modal'; import Component from '@ember/component'; @@ -19,10 +20,15 @@ export default Component.extend(Modals, { sessionService: service('session'), categoryService: service('category'), router: service(), + selectedCategories: A([]), + tagz: A([]), + + unassigned: computed('selectedCategories', 'tagz', function() { + return this.get('selectedCategories').length === 0 && this.get('tagz').length === 0; + }), didReceiveAttrs() { this._super(...arguments); - this.load(); }, diff --git a/gui/app/components/document/zdocument-meta.js b/gui/app/components/document/zdocument-meta.js deleted file mode 100644 index 6a14fd4e..00000000 --- a/gui/app/components/document/zdocument-meta.js +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2016 Documize Inc. . All rights reserved. -// -// This software (Documize Community Edition) is licensed under -// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html -// -// You can operate outside the AGPL restrictions by purchasing -// Documize Enterprise Edition and obtaining a commercial license -// by contacting . -// -// https://documize.com - -import { A } from '@ember/array'; -import { computed } from '@ember/object'; -import { notEmpty } from '@ember/object/computed'; -import { inject as service } from '@ember/service'; -import Modals from '../../mixins/modal'; -import Component from '@ember/component'; - -export default Component.extend(Modals, { - documentService: service('document'), - sessionService: service('session'), - categoryService: service('category'), - router: service(), - contributorMsg: '', - approverMsg: '', - userChanges: notEmpty('contributorMsg'), - isApprover: computed('permissions', function() { - return this.get('permissions.documentApprove'); - }), - isSpaceAdmin: computed('permissions', function() { - return this.get('permissions.spaceOwner') || this.get('permissions.spaceManage'); - }), - changeControlMsg: computed('document.protection', function() { - let p = this.get('document.protection'); - let constants = this.get('constants'); - let msg = ''; - - switch (p) { - case constants.ProtectionType.None: - msg = constants.ProtectionType.NoneLabel; - break; - case constants.ProtectionType.Lock: - msg = constants.ProtectionType.LockLabel; - break; - case constants.ProtectionType.Review: - msg = constants.ProtectionType.ReviewLabel; - break; - } - - return msg; - }), - approvalMsg: computed('document.{protection,approval}', function() { - let p = this.get('document.protection'); - let a = this.get('document.approval'); - let constants = this.get('constants'); - let msg = ''; - - if (p === constants.ProtectionType.Review) { - switch (a) { - case constants.ApprovalType.Anybody: - msg = constants.ApprovalType.AnybodyLabel; - break; - case constants.ApprovalType.Majority: - msg = constants.ApprovalType.MajorityLabel; - break; - case constants.ApprovalType.Unanimous: - msg = constants.ApprovalType.UnanimousLabel; - break; - } - } - - return msg; - }), - - didReceiveAttrs() { - this._super(...arguments); - - this.workflowStatus(); - this.load(); - }, - - workflowStatus() { - let pages = this.get('pages'); - let contributorMsg = ''; - let userPendingCount = 0; - let userReviewCount = 0; - let userRejectedCount = 0; - let approverMsg = ''; - let approverPendingCount = 0; - let approverReviewCount = 0; - let approverRejectedCount = 0; - - pages.forEach((item) => { - if (item.get('userHasChangePending')) userPendingCount+=1; - if (item.get('userHasChangeAwaitingReview')) userReviewCount+=1; - if (item.get('userHasChangeRejected')) userRejectedCount+=1; - if (item.get('changePending')) approverPendingCount+=1; - if (item.get('changeAwaitingReview')) approverReviewCount+=1; - if (item.get('changeRejected')) approverRejectedCount+=1; - }); - - if (userPendingCount > 0 || userReviewCount > 0 || userRejectedCount > 0) { - let label = userPendingCount === 1 ? 'change' : 'changes'; - contributorMsg = `${userPendingCount} ${label} progressing, ${userReviewCount} awaiting review, ${userRejectedCount} rejected`; - } - this.set('contributorMsg', contributorMsg); - - if (approverPendingCount > 0 || approverReviewCount > 0 || approverRejectedCount > 0) { - let label = approverPendingCount === 1 ? 'change' : 'changes'; - approverMsg = `${approverPendingCount} ${label} progressing, ${approverReviewCount} awaiting review, ${approverRejectedCount} rejected`; - } - - this.set('approverMsg', approverMsg); - this.set('selectedVersion', this.get('versions').findBy('documentId', this.get('document.id'))); - }, - - load() { - this.get('categoryService').getDocumentCategories(this.get('document.id')).then((selected) => { - this.set('selectedCategories', selected); - }); - - let tagz = []; - if (!_.isUndefined(this.get('document.tags')) && this.get('document.tags').length > 1) { - let tags = this.get('document.tags').split('#'); - _.each(tags, function(tag) { - if (tag.length > 0) { - tagz.pushObject(tag); - } - }); - } - - this.set('tagz', A(tagz)); - }, - - actions: { - onSelectVersion(version) { - let space = this.get('folder'); - - this.get('router').transitionTo('document', - space.get('id'), space.get('slug'), - version.documentId, this.get('document.slug')); - }, - - onEditLifecycle() { - }, - - onEditProtection() { - }, - - onEditCategory() { - if (!this.get('permissions.spaceManage')) return; - - this.get('router').transitionTo('document.settings', {queryParams: {tab: 'meta'}}); - } - } -}); diff --git a/gui/app/constants/constants.js b/gui/app/constants/constants.js index 0e8c7341..21c45066 100644 --- a/gui/app/constants/constants.js +++ b/gui/app/constants/constants.js @@ -289,6 +289,7 @@ let constants = EmberObject.extend({ Save: 'Save', Search: 'Search', SignIn: 'Sign In', + Unassigned: 'Unassigned', Update: 'Update', Upload: 'Upload' } diff --git a/gui/app/styles/core/view/document/meta.scss b/gui/app/styles/core/view/document/meta.scss index c4f17814..5567a497 100644 --- a/gui/app/styles/core/view/document/meta.scss +++ b/gui/app/styles/core/view/document/meta.scss @@ -10,6 +10,20 @@ margin-bottom: 5px; } + > .text { + margin: 10px 0; + font-size: 1rem; + font-weight: 500; + color: map-get($gray-shades, 600); + } + + > .empty { + margin: 10px 0; + font-size: 1rem; + font-weight: 400; + color: map-get($gray-shades, 600); + } + > .meta-label { @include border-radius(3px); @extend .no-select; diff --git a/gui/app/templates/components/document/document-meta.hbs b/gui/app/templates/components/document/document-meta.hbs index ff55f854..aa4aeac6 100644 --- a/gui/app/templates/components/document/document-meta.hbs +++ b/gui/app/templates/components/document/document-meta.hbs @@ -22,6 +22,16 @@ {{/each}} + {{#if unassigned}} + {{#if permissions.spaceManage}} + {{#ui/ui-toolbar dark=false light=true raised=true large=false bordered=true}} + {{ui/ui-toolbar-icon icon=constants.Icon.Plus color=constants.Color.Gray linkTo="document.settings"}} + {{/ui/ui-toolbar}} + {{else}} +
Unassigned
+ {{/if}} + {{/if}} + {{ui/ui-spacer size=200}}
STATUS
diff --git a/gui/app/templates/components/document/zdocument-meta.hbs b/gui/app/templates/components/document/zdocument-meta.hbs deleted file mode 100644 index d0b8ff1b..00000000 --- a/gui/app/templates/components/document/zdocument-meta.hbs +++ /dev/null @@ -1,13 +0,0 @@ -{{#each selectedCategories as |cat|}} -
- {{cat.category}} - {{#attach-tooltip showDelay=1000}}Category{{/attach-tooltip}} -
-{{/each}} - -{{#each tagz as |t|}} -
- {{#attach-tooltip showDelay=1000}}Tag{{/attach-tooltip}} - {{concat "#" t}} -
-{{/each}}