diff --git a/webapps/src/main/webapp/skin/css/tasks.less b/webapps/src/main/webapp/skin/css/tasks.less index 4f81531c3..0fca4acb8 100644 --- a/webapps/src/main/webapp/skin/css/tasks.less +++ b/webapps/src/main/webapp/skin/css/tasks.less @@ -2858,9 +2858,15 @@ //border: 1px solid #476A9C; animation: beginDrag 1s ease forwards; } - +.active-chip { + box-shadow: -1px 1px #838383, + -2px 2px #9b9b9b, + -3px 3px #a0a0a0, + -4px 4px #c5c5c5, + -5px 5px #d7d7d7 +} .labelsActionMenu { - max-width: 180px !important; + //max-width: 180px !important; min-width: 160px !important; .label-edit-name{ max-width: 136px; @@ -2885,6 +2891,8 @@ } } .v-list-item { + padding-right: 30px !important; + padding-left: 30px !important; min-height: 30px!important; .uiIcon { font-size: 16px; @@ -2892,13 +2900,15 @@ .noColorLabel { border: 1px solid @borderColor; cursor: pointer; + width: 265px; + max-width: 265px; } .projectColorPicker { - width: 144px; - max-width: 144px; + width: 265px; + max-width: 265px; .projectColorCell { - width: 20px; - height: 20px; + width: 40px; + height: 40px; min-width: 20px; min-height: 20px; margin: 2px; diff --git a/webapps/src/main/webapp/vue-app/tasks-management/components/Project/AddProjectDrawer.vue b/webapps/src/main/webapp/vue-app/tasks-management/components/Project/AddProjectDrawer.vue index 08f7788b3..cb45c1d08 100644 --- a/webapps/src/main/webapp/vue-app/tasks-management/components/Project/AddProjectDrawer.vue +++ b/webapps/src/main/webapp/vue-app/tasks-management/components/Project/AddProjectDrawer.vue @@ -90,14 +90,9 @@
- - {{ $t('label.labels') }} - + @set-labels="setLabelsOnCreate"/>
@@ -166,12 +161,8 @@ export default { }); }, methods: { - addLabelOnCreate(label){ - this.labelsToAdd.push(label); - }, - editLabelBeforeCreate(label){ - const objIndex = this.labelsToAdd.findIndex((obj => obj.name === label.name)); - this.labelsToAdd[objIndex].name = label.text; + setLabelsOnCreate(labels) { + this.labelsToAdd = labels; }, open(project) { if (project && project.id){ @@ -219,6 +210,7 @@ export default { description: '', id: '', }; + this.labelsToAdd = []; window.setTimeout(() => { document.dispatchEvent(new CustomEvent('loadAllProjectLabels', { detail: null diff --git a/webapps/src/main/webapp/vue-app/tasks-management/components/Project/EditableLabels.vue b/webapps/src/main/webapp/vue-app/tasks-management/components/Project/EditableLabels.vue index e97b5537a..b385365c1 100644 --- a/webapps/src/main/webapp/vue-app/tasks-management/components/Project/EditableLabels.vue +++ b/webapps/src/main/webapp/vue-app/tasks-management/components/Project/EditableLabels.vue @@ -15,179 +15,60 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --> \ No newline at end of file diff --git a/webapps/src/main/webapp/vue-app/tasks-management/components/Project/ProjectLabels.vue b/webapps/src/main/webapp/vue-app/tasks-management/components/Project/ProjectLabels.vue index 804f0ee4a..0afbe8e94 100644 --- a/webapps/src/main/webapp/vue-app/tasks-management/components/Project/ProjectLabels.vue +++ b/webapps/src/main/webapp/vue-app/tasks-management/components/Project/ProjectLabels.vue @@ -16,45 +16,70 @@ --> @@ -70,76 +95,52 @@ export default { }, data() { return { - index: -1, items: [], - nonce: 1, - model: [], - x: 0, - search: null, - y: 0, + displayActionMenu: false, + labelItem: null, + labelColors: [ + { class: 'asparagus' }, + { class: 'munsell_blue' }, + { class: 'navy_blue' }, + { class: 'purple' }, + { class: 'red' }, + { class: 'brown' }, + { class: 'laurel_green' }, + { class: 'sky_blue' }, + { class: 'blue_gray' }, + { class: 'light_purple' }, + { class: 'hot_pink' }, + { class: 'light_brown' }, + { class: 'moss_green' }, + { class: 'powder_blue' }, + { class: 'light_blue' }, + { class: 'pink' }, + { class: 'Orange' }, + { class: 'gray' }, + { class: 'green' }, + { class: 'baby_blue' }, + { class: 'light_gray' }, + { class: 'beige' }, + { class: 'yellow' }, + { class: 'plum' }, + ], }; }, - watch: { - model(val, prev) { - if (val.length === prev.length) { - this.search = null; - return; - } - this.model = val.map(v => { - if (typeof v === 'string') { - v = { - text: v, - name: v, - }; - this.items.push(v); - this.nonce++; - this.addLabel(v); - } - return v; - }); - }, - - }, created() { - $(document).on('mousedown', () => { - if (this.$refs.selectLabel && this.$refs.selectLabel.isMenuActive) { - window.setTimeout(() => { - this.$refs.selectLabel.isMenuActive = false; - }, 200); - } - }); - document.addEventListener('closeLabelsList',()=> { - setTimeout(() => { - if (typeof this.$refs.selectLabel !== 'undefined') { - this.$refs.selectLabel.isMenuActive = false; - } - }, 100); - }); document.addEventListener('loadAllProjectLabels', event => { - this.model = []; + this.items = []; + this.resetLabelItem(false); if (event && event.detail) { const project = event.detail; - this.model = []; + this.items = []; this.getProjectLabels(project.id); } }); }, methods: { - filter(item, queryText, itemText) { - if (item.header) { - return false; - } - const hasValue = function (val) { - return val != null ? val : ''; - }; - const text = hasValue(itemText); - const query = hasValue(queryText); - return text.toString().toLowerCase().indexOf(query.toString().toLowerCase()) > -1; - }, - getProjectLabels(projectId) { this.$taskDrawerApi.getProjectLabels(projectId).then((labels) => { - this.model = labels.map(function (el) { + this.items = labels.map(function (el) { const o = Object.assign({}, el); o.text = o.name; o.editMenu=false; @@ -147,7 +148,6 @@ export default { }); }); }, - addLabel(label) { if ( this.project.id!= null ) { label.project=this.project; @@ -156,6 +156,7 @@ export default { type: 'success', message: this.$t('alert.success.label.created') }); + this.resetLabelItem(false); this.getProjectLabels(this.project.id); }).catch(e => { console.error('Error when adding labels', e); @@ -165,31 +166,82 @@ export default { }); }); } else { - this.$emit('add-label', label); + this.items.push(label); + this.$emit('set-labels', this.items); + this.resetLabelItem(true); } - this.model.push(label); - document.getElementById('labelInput').focus(); }, - - removeLabel(item) { - this.$taskDrawerApi.removeLabel(item.id).then( () => { + editLabel(label) { + label.name=label.text; + this.$taskDrawerApi.editLabel(label).then( (editedLabel) => { + label=editedLabel; + label.text = label.name; this.$root.$emit('show-alert', { type: 'success', - message: this.$t('alert.success.label.deleted') + message: this.$t('alert.success.label.updated') }); + this.resetLabelItem(false); }).catch(e => { - console.error('Error when removibg labels', e); + console.error('Error when editing label', e); this.$root.$emit('show-alert', { type: 'error', message: this.$t('alert.error') }); }); }, - openLabelsList() { - this.$emit('labelsListOpened'); + removeLabel(item, index) { + if (item.project) { + this.$taskDrawerApi.removeLabel(item.id).then(() => { + this.$root.$emit('show-alert', { + type: 'success', + message: this.$t('alert.success.label.deleted') + }); + + }).catch(e => { + console.error('Error when removing label', e); + this.$root.$emit('show-alert', { + type: 'error', + message: this.$t('alert.error') + }); + }); + } + if (index != null && index > -1) { + this.items.splice(index, 1); + } + this.resetLabelItem(false); + }, + saveLabel() { + if ( !this.labelItem.text) { + return; + } + if (this.labelItem.project) { + this.editLabel(this.labelItem); + } else { + this.labelItem.name = this.labelItem.text; + this.addLabel(this.labelItem); + } }, - editLabelBeforeCreate(label) { - this.$emit('edit-label-on-create', label); + resetLabelItem(displayActionMenu, item) { + if (item) { + this.labelItem = item; + } else { + this.labelItem = { + text: '', + }; + } + + this.displayActionMenu = displayActionMenu; + + if (displayActionMenu) { + setTimeout(() => { + const el = this.$el.querySelector('.labelsActionMenu .v-text-field input'); + el.setSelectionRange(el.value.length, el.value.length); + el.focus(); + this.$el.querySelector('.projectColorPicker').scrollIntoView({ behavior: 'smooth' }); + }, 100); + } + + this.$refs.childLabel.resetActiveItem(item); } } };