1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 21:29:42 +02:00

Document meta fields: better popovers & click-through editing

Non-admins receive popovers on hover.

Admins receive no popovers and get click-through to settings tab.

Space and document settings support jump to sub-section.

Co-Authored-By: Harvey Kandola <harvey@documize.com>
This commit is contained in:
sauls8t 2018-06-25 19:43:29 +01:00
parent 5d80480d75
commit ad44112359
6 changed files with 65 additions and 34 deletions

View file

@ -22,6 +22,7 @@ export default Component.extend(Modals, Tooltips, {
documentService: service('document'), documentService: service('document'),
sessionService: service('session'), sessionService: service('session'),
categoryService: service('category'), categoryService: service('category'),
router: service(),
contributorMsg: '', contributorMsg: '',
approverMsg: '', approverMsg: '',
@ -29,6 +30,9 @@ export default Component.extend(Modals, Tooltips, {
isApprover: computed('permissions', function() { isApprover: computed('permissions', function() {
return this.get('permissions.documentApprove'); return this.get('permissions.documentApprove');
}), }),
isSpaceAdmin: computed('permissions', function() {
return this.get('permissions.spaceOwner') || this.get('permissions.spaceManage');
}),
changeControlMsg: computed('document.protection', function() { changeControlMsg: computed('document.protection', function() {
let p = this.get('document.protection'); let p = this.get('document.protection');
let constants = this.get('constants'); let constants = this.get('constants');
@ -97,32 +101,45 @@ export default Component.extend(Modals, Tooltips, {
popovers() { popovers() {
let constants = this.get('constants'); let constants = this.get('constants');
$('#document-lifecycle-popover').popover('dispose'); if (this.get('permissions.documentLifecycle')) {
$('#document-protection-popover').popover('dispose'); $('#document-lifecycle-popover').addClass('cursor-pointer');
} else {
$('#document-lifecycle-popover').popover('dispose');
$('#document-lifecycle-popover').removeClass('cursor-pointer');
$('#document-lifecycle-popover').popover({ $('#document-lifecycle-popover').popover({
html: true, html: true,
title: 'Lifecycle', title: 'Lifecycle',
content: "<p>Draft &mdash; restricted visiblity and not searchable</p><p>Live &mdash; document visible to all</p><p>Archived &mdash; not visible or searchable</p>", content: "<p>Draft &mdash; restricted visiblity and not searchable</p><p>Live &mdash; document visible to all</p><p>Archived &mdash; not visible or searchable</p>",
placement: 'top' placement: 'top',
}); trigger: 'hover click'
});
let ccMsg = `<p>${this.changeControlMsg}</p>`;
if (this.get('document.protection') === constants.ProtectionType.Review) {
ccMsg += '<ul>'
ccMsg += `<li>${this.approvalMsg}</li>`;
if (this.get('userChanges')) ccMsg += `<li>Your contributions: ${this.contributorMsg}</li>`;
if (this.get('isApprover') && this.get('approverMsg.length') > 0) ccMsg += `<li>${this.approverMsg}</li>`;
ccMsg += '</ul>'
} }
$('#document-protection-popover').popover({ if (this.get('permissions.documentApprove')) {
html: true, $('#document-protection-popover').addClass('cursor-pointer');
title: 'Change Control', } else {
content: ccMsg, $('#document-protection-popover').popover('dispose');
placement: 'top' $('#document-protection-popover').removeClass('cursor-pointer');
});
let ccMsg = `<p>${this.changeControlMsg}</p>`;
if (this.get('document.protection') === constants.ProtectionType.Review) {
ccMsg += '<ul>'
ccMsg += `<li>${this.approvalMsg}</li>`;
if (this.get('userChanges')) ccMsg += `<li>Your contributions: ${this.contributorMsg}</li>`;
if (this.get('isApprover') && this.get('approverMsg.length') > 0) ccMsg += `<li>${this.approverMsg}</li>`;
ccMsg += '</ul>'
}
$('#document-protection-popover').popover({
html: true,
title: 'Change Control',
content: ccMsg,
placement: 'top',
trigger: 'hover click'
});
}
}, },
workflowStatus() { workflowStatus() {
@ -187,6 +204,20 @@ export default Component.extend(Modals, Tooltips, {
this.get('router').transitionTo('document', this.get('router').transitionTo('document',
space.get('id'), space.get('slug'), space.get('id'), space.get('slug'),
version.documentId, this.get('document.slug')); version.documentId, this.get('document.slug'));
},
onEditLifecycle() {
//no op
},
onEditProtection() {
//no op
},
onEditCategory() {
if (!this.get('permissions.spaceManage')) return;
this.get('router').transitionTo('document.settings', {queryParams: {tab: 'meta'}});
} }
} }
}); });

View file

@ -18,6 +18,7 @@ export default Controller.extend(Notifier, {
folderService: service('folder'), folderService: service('folder'),
documentService: service('document'), documentService: service('document'),
localStorage: service('localStorage'), localStorage: service('localStorage'),
queryParams: ['tab'],
tab: 'general', tab: 'general',
actions: { actions: {

View file

@ -17,6 +17,7 @@ export default Controller.extend(NotifierMixin, {
router: service(), router: service(),
folderService: service('folder'), folderService: service('folder'),
localStorage: service('localStorage'), localStorage: service('localStorage'),
queryParams: ['tab'],
tab: 'general', tab: 'general',
actions: { actions: {

View file

@ -24,7 +24,6 @@
background-color: $color-off-white; background-color: $color-off-white;
font-weight: 800; font-weight: 800;
font-size: 1rem; font-size: 1rem;
cursor: pointer;
&:hover { &:hover {
color: $color-green; color: $color-green;
@ -50,7 +49,6 @@
color: $color-gray; color: $color-gray;
background-color: $color-off-white; background-color: $color-off-white;
border: 2px solid $color-gray; border: 2px solid $color-gray;
cursor: pointer;
&:hover { &:hover {
color: $color-dark; color: $color-dark;

View file

@ -1,28 +1,28 @@
{{#if (eq document.lifecycle constants.Lifecycle.Live)}} {{#if (eq document.lifecycle constants.Lifecycle.Live)}}
<div id="document-lifecycle-popover" class="document-lifecycle-live text-uppercase">{{document.lifecycleLabel}}</div> <div id="document-lifecycle-popover" class="document-lifecycle-live text-uppercase" {{action 'onEditLifecycle'}}>{{document.lifecycleLabel}}</div>
{{/if}} {{/if}}
{{#if (eq document.lifecycle constants.Lifecycle.Draft)}} {{#if (eq document.lifecycle constants.Lifecycle.Draft)}}
<div id="document-lifecycle-popover" class="document-lifecycle-draft text-uppercase">{{document.lifecycleLabel}}</div> <div id="document-lifecycle-popover" class="document-lifecycle-draft text-uppercase" {{action 'onEditLifecycle'}}>{{document.lifecycleLabel}}</div>
{{/if}} {{/if}}
<div class="d-block d-sm-none margin-top-20" /> <div class="d-block d-sm-none margin-top-20" />
<div class="d-sm-inline-block margin-left-20" /> <div class="d-sm-inline-block margin-left-20" />
{{#if (eq document.protection constants.ProtectionType.None)}} {{#if (eq document.protection constants.ProtectionType.None)}}
<div id="document-protection-popover" class="document-protection-unlocked text-uppercase">OPEN</div> <div id="document-protection-popover" class="document-protection-unlocked text-uppercase" {{action 'onEditProtection'}}>OPEN</div>
{{/if}} {{/if}}
{{#if (eq document.protection constants.ProtectionType.Review)}} {{#if (eq document.protection constants.ProtectionType.Review)}}
<div id="document-protection-popover" class="document-protection-review text-uppercase">PROTECTED</div> <div id="document-protection-popover" class="document-protection-review text-uppercase" {{action 'onEditProtection'}}>PROTECTED</div>
{{/if}} {{/if}}
{{#if (eq document.protection constants.ProtectionType.Lock)}} {{#if (eq document.protection constants.ProtectionType.Lock)}}
<div id="document-protection-popover" class="document-protection-locked text-uppercase">LOCKED</div> <div id="document-protection-popover" class="document-protection-locked text-uppercase" {{action 'onEditProtection'}}>LOCKED</div>
{{/if}} {{/if}}
<div class="d-block d-sm-none margin-top-20" /> <div class="d-block d-sm-none margin-top-20" />
<div class="d-sm-inline-block margin-left-20" /> <div class="d-sm-inline-block margin-left-20" />
{{#each selectedCategories as |cat|}} {{#each selectedCategories as |cat|}}
<div class="document-category" data-toggle="tooltip" data-placement="top" title="Category"> <div class="document-category {{if isSpaceAdmin 'cursor-pointer'}}" data-toggle="tooltip" data-placement="top" title="Category">
{{cat.category}} {{cat.category}}
</div> </div>
{{/each}} {{/each}}
@ -30,13 +30,13 @@
<div class="d-block d-sm-none margin-top-20" /> <div class="d-block d-sm-none margin-top-20" />
{{#each tagz as |t index|}} {{#each tagz as |t index|}}
<div class="document-tag" data-toggle="tooltip" data-placement="top" title="Tag"> <div class="document-tag {{if isSpaceAdmin 'cursor-pointer'}}" data-toggle="tooltip" data-placement="top" title="Tag" {{action 'onEditCategory'}}>
{{concat '#' t}} {{concat '#' t}}
</div> </div>
{{/each}} {{/each}}
<div class="document-meta"> <div class="document-meta">
{{document/view-attachment document=document permissions=permissions}} {{document/view-attachment document=document permissions=permissions {{action 'onEditCategory'}}}}
</div> </div>
<div class="margin-top-70" /> <div class="margin-top-70" />

View file

@ -29,7 +29,7 @@
{{#if spaceSettings}} {{#if spaceSettings}}
<div class="text-center {{if (gt categories.length 0) 'mt-4'}}"> <div class="text-center {{if (gt categories.length 0) 'mt-4'}}">
{{#link-to 'folder.settings' space.id space.slug class="btn btn-secondary font-weight-bold"}}{{categoryLinkName}}{{/link-to}} {{#link-to 'folder.settings' space.id space.slug (query-params tab="categories") class="btn btn-secondary font-weight-bold"}}{{categoryLinkName}}{{/link-to}}
</div> </div>
{{/if}} {{/if}}
</div> </div>