mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
document category picker
This commit is contained in:
parent
60fb4e5008
commit
8415f11303
9 changed files with 203 additions and 120 deletions
|
@ -10,19 +10,17 @@
|
|||
// https://documize.com
|
||||
|
||||
import { computed } from '@ember/object';
|
||||
|
||||
import { inject as service } from '@ember/service';
|
||||
import Component from '@ember/component';
|
||||
import { A } from "@ember/array"
|
||||
import TooltipMixin from '../../mixins/tooltip';
|
||||
import NotifierMixin from '../../mixins/notifier';
|
||||
|
||||
export default Component.extend(TooltipMixin, NotifierMixin, {
|
||||
export default Component.extend({
|
||||
documentService: service('document'),
|
||||
categoryService: service('category'),
|
||||
sessionService: service('session'),
|
||||
newCategory: '',
|
||||
categories: A([]),
|
||||
showCategoryModal: false,
|
||||
hasCategories: computed('categories', function() {
|
||||
return this.get('categories').length > 0;
|
||||
}),
|
||||
|
@ -53,10 +51,26 @@ export default Component.extend(TooltipMixin, NotifierMixin, {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
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: {
|
||||
onSave() {
|
||||
onShowCategoryModal() {
|
||||
this.set('showCategoryModal', true);
|
||||
},
|
||||
|
||||
onSaveCategory() {
|
||||
let docId = this.get('document.id');
|
||||
let folderId = this.get('folder.id');
|
||||
let link = this.get('categories').filterBy('selected', true);
|
||||
|
@ -86,6 +100,8 @@ export default Component.extend(TooltipMixin, NotifierMixin, {
|
|||
toUnlink.pushObject(t);
|
||||
});
|
||||
|
||||
this.set('showCategoryModal', false);
|
||||
|
||||
this.get('categoryService').setCategoryMembership(toUnlink, 'unlink').then(() => {
|
||||
this.get('categoryService').setCategoryMembership(toLink, 'link').then(() => {
|
||||
this.load();
|
|
@ -9,35 +9,22 @@
|
|||
{{/toolbar/t-toolbar}}
|
||||
|
||||
{{document/document-heading document=model.document permissions=model.permissions onSaveDocument=(action 'onSaveDocument')}}
|
||||
{{document/document-meta document=model.document folder=model.folder folders=model.folders permissions=model.permissions}}
|
||||
{{document/tag-editor documentTags=model.document.tags permissions=model.permissions onChange=(action 'onTagChange')}}
|
||||
|
||||
<div id="zone-document-content" class="zone-document-content">
|
||||
<div class="document-header-zone">
|
||||
<div class="pull-left">
|
||||
{{document/space-category document=model.document folder=model.folder folders=model.folders permissions=model.permissions}}
|
||||
</div>
|
||||
|
||||
<div class="pull-right">
|
||||
{{document/document-toolbar
|
||||
document=model.document folder=model.folder folders=model.folders permissions=model.permissions
|
||||
onDocumentDelete=(action 'onDocumentDelete') onSaveTemplate=(action 'onSaveTemplate')
|
||||
onPageSequenceChange=(action 'onPageSequenceChange') onPageLevelChange=(action 'onPageLevelChange')
|
||||
onGotoPage=(action 'onGotoPage')}}
|
||||
</div>
|
||||
<div class="clearfix"/>
|
||||
|
||||
{{document/tag-editor documentTags=model.document.tags permissions=model.permissions onChange=(action 'onTagChange')}}
|
||||
{{document/document-toolbar
|
||||
document=model.document folder=model.folder folders=model.folders permissions=model.permissions
|
||||
onDocumentDelete=(action 'onDocumentDelete') onSaveTemplate=(action 'onSaveTemplate')
|
||||
onPageSequenceChange=(action 'onPageSequenceChange') onPageLevelChange=(action 'onPageLevelChange')
|
||||
onGotoPage=(action 'onGotoPage')}}
|
||||
</div>
|
||||
|
||||
|
||||
{{document/document-sidebar tab=tab
|
||||
document=model.document folder=model.folder pages=model.pages page=model.page permissions=model.permissions
|
||||
onPageSequenceChange=(action 'onPageSequenceChange') onPageLevelChange=(action 'onPageLevelChange')
|
||||
onGotoPage=(action 'onGotoPage')}}
|
||||
|
||||
|
||||
{{#if model.document.template}}
|
||||
<div class="document-template-header">Template</div>
|
||||
{{/if}}
|
||||
{{document/document-sidebar tab=tab
|
||||
document=model.document folder=model.folder pages=model.pages page=model.page permissions=model.permissions
|
||||
onPageSequenceChange=(action 'onPageSequenceChange') onPageLevelChange=(action 'onPageLevelChange')
|
||||
onGotoPage=(action 'onGotoPage')}}
|
||||
|
||||
{{document/document-view
|
||||
document=model.document links=model.links pages=model.pages
|
||||
|
|
|
@ -23,18 +23,34 @@
|
|||
> .document-customfields {
|
||||
margin-bottom: 4rem;
|
||||
|
||||
.heading {
|
||||
font-size: 1.1rem;
|
||||
font-weight: bold;
|
||||
color: $color-gray;
|
||||
text-align: left;
|
||||
}
|
||||
.row {
|
||||
padding: 5px 0;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.value {
|
||||
font-size: 1.1rem;
|
||||
font-weight: normal;
|
||||
color: $color-black;
|
||||
text-align: left;
|
||||
&:hover {
|
||||
.action-button {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
|
||||
.heading {
|
||||
font-size: 1.1rem;
|
||||
font-weight: bold;
|
||||
color: $color-gray;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.action-button {
|
||||
visibility: hidden;
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: 1.1rem;
|
||||
font-weight: normal;
|
||||
color: $color-black;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -354,9 +354,3 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.document-template-header {
|
||||
color: $color-goldy;
|
||||
font-size: 1.5em;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
{{#unless editMode}}
|
||||
<div class="view-document">
|
||||
<div class="document-heading {{if permissions.documentEdit 'cursor-pointer'}}" onclick={{if permissions.documentEdit (action 'toggleEdit')}}>
|
||||
<h1 class="doc-title">{{document.name}}</h1>
|
||||
<h1 class="doc-title">
|
||||
{{#if document.template}}
|
||||
<span class="bg-warning p-1 pr-2 pl-2">Template</span>
|
||||
{{/if}}
|
||||
{{document.name}}
|
||||
</h1>
|
||||
<div class="doc-excerpt">{{document.excerpt}}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
48
gui/app/templates/components/document/document-meta.hbs
Normal file
48
gui/app/templates/components/document/document-meta.hbs
Normal file
|
@ -0,0 +1,48 @@
|
|||
<div class="view-document">
|
||||
<div class="document-customfields">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-2 heading">Categories
|
||||
{{#if canSelectCategory}}
|
||||
<div class="action-button button-icon-green button-icon-small align-middle" {{action 'onShowCategoryModal'}}>
|
||||
<i class="material-icons align-middle">edit</i>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="col-10 value">
|
||||
{{#each selectedCategories as |cat|}}
|
||||
{{#link-to 'folder' folder.id folder.slug (query-params category=cat.id)}}
|
||||
{{cat.category}}
|
||||
{{/link-to}}
|
||||
|
||||
{{else}}
|
||||
{{#if canAddCategory}}
|
||||
{{#if canSelectCategory}}
|
||||
<a href="#" {{action 'onShowCategoryModal'}}><select></a>
|
||||
{{else}}
|
||||
{{#link-to 'folder.category' folder.id folder.slug class='non-printable'}}Manage{{/link-to}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-2 heading">Tags</div>
|
||||
<div class="col-10 value">
|
||||
{{#each tagz as |t index|}}
|
||||
<a href="/search?tag={{t}}">{{concat '#' t}}</a>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if permissions.documentEdit}}
|
||||
{{#ui/ui-dialog title="Set Document Cateogories" confirmCaption="Select" buttonType="btn-outline-success" show=showCategoryModal onAction=(action 'onSaveCategory')}}
|
||||
<p>Select who can view documents within category</p>
|
||||
{{ui/ui-list-picker items=categories nameField='category' singleSelect=false}}
|
||||
{{/ui/ui-dialog}}
|
||||
{{/if}}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
<div class="view-document">
|
||||
<div class="document-customfields">
|
||||
<div class="row">
|
||||
<div class="col-2 heading">
|
||||
Categories
|
||||
</div>
|
||||
<div class="col-10 value">
|
||||
{{#each selectedCategories as |cat|}}
|
||||
{{cat.category}}{{#unless cat.lastObject}}, {{/unless}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if canAddCategory}}
|
||||
{{#unless canSelectCategory}}
|
||||
{{#link-to 'folder.category' folder.id folder.slug class='non-printable'}}Manage{{/link-to}}
|
||||
{{/unless}}
|
||||
{{else}}
|
||||
<p> </p>
|
||||
{{/if}}
|
||||
|
||||
{{#if canSelectCategory}}
|
||||
<div class="regular-button button-white" id="document-category-button">
|
||||
<i class="material-icons">add</i>
|
||||
</div>
|
||||
{{#dropdown-dialog target="document-category-button" position="bottom right" button="set" color="flat-green" onAction=(action 'onSave')}}
|
||||
<p class="heading">Set document categories</p>
|
||||
<div class="document-category-dialog">
|
||||
{{ui/ui-list-picker items=categories nameField='category'}}
|
||||
{{#if canAddCategory}}
|
||||
{{#link-to 'folder.category' folder.id folder.slug}}Manage{{/link-to}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/dropdown-dialog}}
|
||||
{{/if}}
|
Loading…
Add table
Add a link
Reference in a new issue