1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-25 08:09:43 +02:00

Per space label, icon, description

Labels introduce visual grouping and filtering of spaces.
This commit is contained in:
McMatts 2019-01-04 16:33:30 +00:00
parent fe8068965c
commit a211ba051a
106 changed files with 3280 additions and 1008 deletions

View file

@ -0,0 +1,94 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
//
// https://documize.com
import $ from 'jquery';
import Modals from '../../mixins/modal';
import Component from '@ember/component';
export default Component.extend(Modals, {
labelName: '',
labelColor: '',
editLabel: null,
deleetLabel: null,
showDeleteDialog: false,
actions: {
onShowAddModal() {
this.set('labelName', '');
this.set('labelColor', '');
this.modalOpen("#add-label-modal", {"show": true}, '#add-label-name');
},
onShowDeleteModal(label) {
this.set('deleteLabel', label);
this.set('showDeleteDialog', !this.get('showDeleteDialog'));
},
onShowUpdateModal(label) {
this.set('editLabel', label);
this.set('labelName', label.get('name'));
this.set('labelColor', label.get('color'));
this.modalOpen("#edit-label-modal", {"show": true}, '#edit-label-name');
},
onSetColor(color) {
this.set('labelColor', color);
},
onAdd() {
let label = {
name: this.get('labelName').trim(),
color: this.get('labelColor').trim(),
}
if (is.empty(label.name)) {
$('#add-label-name').addClass('is-invalid').focus();
return;
}
$('#add-label-name').removeClass('is-invalid');
this.modalClose('#add-label-modal');
this.get('onAdd')(label);
},
onUpdate() {
let name = this.get('labelName').trim();
let color = this.get('labelColor').trim();
let label = this.get('editLabel');
if (is.empty(name)) {
$('#edit-label-name').addClass('is-invalid').focus();
return;
}
$('#edit-label-name').removeClass('is-invalid');
this.modalClose('#edit-label-modal');
label.set('name', name);
label.set('color', color);
this.get('onUpdate')(label);
this.set('editLabel', null);
},
onDelete() {
let label = this.get('deleteLabel');
this.set('showDeleteDialog', false);
this.get('onDelete')(label.get('id'));
this.set('deleteLabel', null);
return true;
}
}
});

View file

@ -71,11 +71,6 @@ export default Component.extend(ModalMixin, AuthMixin, Notifier, {
this.set('saveTemplate.description', this.get('document.excerpt'));
},
didInsertElement() {
this._super(...arguments);
this.modalInputFocus('#document-template-modal', '#new-template-name');
},
willDestroyElement() {
this._super(...arguments);
},

View file

@ -17,6 +17,7 @@ import Notifier from '../../mixins/notifier';
import Component from '@ember/component';
export default Component.extend(Modals, Notifier, {
classNames: ["section"],
documentService: service('document'),
browserSvc: service('browser'),
appMeta: service(),
@ -50,7 +51,7 @@ export default Component.extend(Modals, Notifier, {
let url = this.get('appMeta.endpoint');
let uploadUrl = `${url}/documents/${documentId}/attachments`;
let dzone = new Dropzone("#upload-document-files", {
let dzone = new Dropzone("#upload-document-files > div", {
headers: {
'Authorization': 'Bearer ' + self.get('session.authToken')
},

View file

@ -9,7 +9,6 @@
//
// 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';

View file

@ -21,17 +21,27 @@ export default Component.extend(AuthMixin, Notifier, {
router: service(),
spaceSvc: service('folder'),
localStorage: service('localStorage'),
isSpaceAdmin: computed('permissions', function() {
return this.get('permissions.spaceOwner') || this.get('permissions.spaceManage');
}),
spaceName: '',
hasNameError: empty('spaceName'),
spaceTypeOptions: A([]),
spaceType: 0,
likes: '',
allowLikes: false,
spaceLifecycleOptions: A([]),
spaceLifecycle: null,
iconList: A([]),
spaceIcon: '',
spaceDesc: '',
spaceLabel: '',
init() {
this._super(...arguments);
this.populateIconList();
},
didReceiveAttrs() {
this._super(...arguments);
@ -55,6 +65,71 @@ export default Component.extend(AuthMixin, Notifier, {
}
this.set('spaceName', this.get('space.name'));
this.set('spaceDesc', this.get('space.desc'));
this.set('spaceLabel', this.get('space.labelId'));
let icon = this.get('space.icon');
if (is.empty(icon)) {
icon = constants.IconMeta.Apps;
}
this.set('spaceIcon', icon);
},
populateIconList() {
let list = this.get('iconList');
let constants = this.get('constants');
list = A([]);
list.pushObject(constants.IconMeta.Star);
list.pushObject(constants.IconMeta.Support);
list.pushObject(constants.IconMeta.Message);
list.pushObject(constants.IconMeta.Apps);
list.pushObject(constants.IconMeta.Box);
list.pushObject(constants.IconMeta.Gift);
list.pushObject(constants.IconMeta.Design);
list.pushObject(constants.IconMeta.Bulb);
list.pushObject(constants.IconMeta.Metrics);
list.pushObject(constants.IconMeta.PieChart);
list.pushObject(constants.IconMeta.BarChart);
list.pushObject(constants.IconMeta.Finance);
list.pushObject(constants.IconMeta.Lab);
list.pushObject(constants.IconMeta.Code);
list.pushObject(constants.IconMeta.Help);
list.pushObject(constants.IconMeta.Manuals);
list.pushObject(constants.IconMeta.Flow);
list.pushObject(constants.IconMeta.Out);
list.pushObject(constants.IconMeta.In);
list.pushObject(constants.IconMeta.Partner);
list.pushObject(constants.IconMeta.Org);
list.pushObject(constants.IconMeta.Home);
list.pushObject(constants.IconMeta.Infinite);
list.pushObject(constants.IconMeta.Todo);
list.pushObject(constants.IconMeta.Procedure);
list.pushObject(constants.IconMeta.Outgoing);
list.pushObject(constants.IconMeta.Incoming);
list.pushObject(constants.IconMeta.Travel);
list.pushObject(constants.IconMeta.Winner);
list.pushObject(constants.IconMeta.Roadmap);
list.pushObject(constants.IconMeta.Money);
list.pushObject(constants.IconMeta.Security);
list.pushObject(constants.IconMeta.Tune);
list.pushObject(constants.IconMeta.Guide);
list.pushObject(constants.IconMeta.Smile);
list.pushObject(constants.IconMeta.Rocket);
list.pushObject(constants.IconMeta.Time);
list.pushObject(constants.IconMeta.Cup);
list.pushObject(constants.IconMeta.Marketing);
list.pushObject(constants.IconMeta.Announce);
list.pushObject(constants.IconMeta.Devops);
list.pushObject(constants.IconMeta.World);
list.pushObject(constants.IconMeta.Plan);
list.pushObject(constants.IconMeta.Components);
list.pushObject(constants.IconMeta.People);
list.pushObject(constants.IconMeta.Checklist);
this.set('iconList', list);
},
actions: {
@ -62,6 +137,18 @@ export default Component.extend(AuthMixin, Notifier, {
this.set('spaceType', t);
},
onSetSpaceLifecycle(l) {
this.set('spaceLifecycle', l);
},
onSetIcon(icon) {
this.set('spaceIcon', icon);
},
onSetLabel(id) {
this.set('spaceLabel', id);
},
onSave() {
if (!this.get('isSpaceAdmin')) return;
@ -75,6 +162,10 @@ export default Component.extend(AuthMixin, Notifier, {
if (spaceName.length === 0) return;
space.set('name', spaceName);
space.set('icon', this.get('spaceIcon'));
space.set('desc', this.get('spaceDesc'));
space.set('labelId', this.get('spaceLabel'));
this.get('spaceSvc').save(space).then(() => {
this.notifySuccess('Saved');
});

View file

@ -28,6 +28,7 @@ export default Component.extend(AuthMixin, {
return this.get('permissions.spaceOwner') || this.get('permissions.spaceManage');
}),
selectedFilter: '',
spaceLabel: null,
init() {
this._super(...arguments);
@ -55,6 +56,7 @@ export default Component.extend(AuthMixin, {
this.set('categories', categories);
this.set('categoryLinkName', categories.length > 0 ? 'Manage' : 'Add');
this.set('spaceLabel', _.findWhere(this.get('labels'), {id: this.get('space.labelId')}));
schedule('afterRender', () => {
if (this.get('categoryFilter') !== '') {

View file

@ -12,4 +12,6 @@
import Component from '@ember/component';
export default Component.extend({
icon: null,
meta: null
});

View file

@ -30,6 +30,7 @@ export default Component.extend(Modals, {
hasDocumentPins: notEmpty('documentPins'),
hasWhatsNew: false,
newsContent: '',
hideNavigation: false,
init() {
this._super(...arguments);

View file

@ -0,0 +1,29 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
//
// https://documize.com
import { computed } from '@ember/object';
import Component from '@ember/component';
export default Component.extend({
tagName: 'div',
classNames: ['space-label'],
attributeBindings: ['customStyle:style'],
customStyle: computed('label', function() {
return this.get('label.bgColor');
}),
label: null,
didReceiveAttrs() {
this._super(...arguments);
this.set('label', _.findWhere(this.get('labels'), {id: this.get('labelId')}));
}
});

View file

@ -0,0 +1,85 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
//
// https://documize.com
import { A } from '@ember/array';
import { inject as service } from '@ember/service';
import { set } from '@ember/object';
import Component from '@ember/component';
export default Component.extend({
appMeta: service(),
onChange: null,
colors: null,
didReceiveAttrs() {
this._super(...arguments);
let colors = A([]);
colors.pushObject({selected: false, code: '#263238'});
colors.pushObject({selected: false, code: '#37474f'});
colors.pushObject({selected: false, code: '#455a64'});
colors.pushObject({selected: false, code: '#546e7a'});
colors.pushObject({selected: false, code: '#4c4c4c'});
colors.pushObject({selected: false, code: '#757575'});
colors.pushObject({selected: false, code: '#616161'});
colors.pushObject({selected: false, code: '#d50000'});
colors.pushObject({selected: false, code: '#b71c1c'});
colors.pushObject({selected: false, code: '#880e4f'});
colors.pushObject({selected: false, code: '#c2185b'});
colors.pushObject({selected: false, code: '#4a148c'});
colors.pushObject({selected: false, code: '#6a1b9a'});
colors.pushObject({selected: false, code: '#7b1fa2'});
colors.pushObject({selected: false, code: '#311b92'});
colors.pushObject({selected: false, code: '#0d47a1'});
colors.pushObject({selected: false, code: '#1565c0'});
colors.pushObject({selected: false, code: '#2962ff'});
colors.pushObject({selected: false, code: '#039be5'});
colors.pushObject({selected: false, code: '#00838f'});
colors.pushObject({selected: false, code: '#006064'});
colors.pushObject({selected: false, code: '#00897b'});
colors.pushObject({selected: false, code: '#2e7d32'});
colors.pushObject({selected: false, code: '#388e3c'});
colors.pushObject({selected: false, code: '#4caf50'});
colors.pushObject({selected: false, code: '#33691e'});
colors.pushObject({selected: false, code: '#827717'});
colors.pushObject({selected: false, code: '#f9a825'});
colors.pushObject({selected: false, code: '#ffca28'});
colors.pushObject({selected: false, code: '#ef6c00'});
colors.pushObject({selected: false, code: '#bf360c'});
colors.pushObject({selected: false, code: '#ff3d00'});
colors.pushObject({selected: false, code: '#4e342e'});
colors.pushObject({selected: false, code: '#6d4c41'});
colors.pushObject({selected: false, code: '#8d6e63'});
this.set('colors', colors);
// Send back default color code in case user does not select
// their own preference.
this.setColor(colors[0].code);
},
setColor(colorCode) {
let colors = this.get('colors');
_.each(colors, (color) => {
set(color, 'selected', color.code === colorCode ? true: false);
});
if (this.get('onChange') !== null) {
this.get('onChange')(colorCode);
}
},
actions: {
onSelect(colorCode) {
this.setColor(colorCode);
}
}
});

View file

@ -0,0 +1,35 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. 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 <sales@documize.com>.
//
// https://documize.com
import { computed } from '@ember/object';
import Component from '@ember/component';
export default Component.extend({
tagName: 'i',
classNames: [''],
classNameBindings: ['calcClass'],
icon: null,
calcClass: computed(function() {
let icon = this.icon;
let constants = this.get('constants');
if (is.null(icon)) {
return '';
}
if (is.empty(icon)) {
icon = constants.IconMeta.Apps;
}
return 'dmeta ' + icon;
})
});