mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 14:45:56 +08:00
Fix select dropdown changes [SCI-8865]
This commit is contained in:
parent
e67f7c8caf
commit
967178654e
|
@ -17,6 +17,7 @@
|
|||
:optionsUrl="projectsUrl"
|
||||
:searchable="true"
|
||||
:value="selectedProject"
|
||||
:optionRenderer="newProjectRenderer"
|
||||
@change="changeProject"
|
||||
/>
|
||||
</div>
|
||||
|
@ -44,6 +45,7 @@
|
|||
:disabled="!(selectedProject != null && selectedProject >= 0)"
|
||||
:searchable="true"
|
||||
:value="selectedExperiment"
|
||||
:optionRenderer="newExperimentRenderer"
|
||||
@change="changeExperiment"
|
||||
/>
|
||||
</div>
|
||||
|
@ -157,6 +159,18 @@ export default {
|
|||
this.selectedExperiment = value;
|
||||
this.newExperimentName = label;
|
||||
},
|
||||
newProjectRenderer(option) {
|
||||
if (option[0] > 0) {
|
||||
return option[1];
|
||||
}
|
||||
return this.i18n.t('dashboard.create_task_modal.new_project', { name: option[1] });
|
||||
},
|
||||
newExperimentRenderer(option) {
|
||||
if (option[0] > 0) {
|
||||
return option[1];
|
||||
}
|
||||
return this.i18n.t('dashboard.create_task_modal.new_experiment', { name: option[1] });
|
||||
},
|
||||
closeModal() {
|
||||
$('#create-task-modal').modal('hide');
|
||||
this.taskName = '';
|
||||
|
|
|
@ -273,8 +273,13 @@ export default {
|
|||
});
|
||||
}
|
||||
},
|
||||
urlParams() {
|
||||
this.fetchOptions();
|
||||
urlParams: {
|
||||
handler(oldVal, newVal) {
|
||||
if (!this.compareObjects(oldVal, newVal)) {
|
||||
this.fetchOptions();
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -384,6 +389,11 @@ export default {
|
|||
if (this.$refs.options) {
|
||||
this.$refs.options[this.focusedOption]?.scrollIntoView({ block: 'nearest' });
|
||||
}
|
||||
},
|
||||
compareObjects(o1, o2) {
|
||||
const normalizedObj1 = Object.fromEntries(Object.entries(o1).sort(([k1], [k2]) => k1.localeCompare(k2)));
|
||||
const normalizedObj2 = Object.fromEntries(Object.entries(o2).sort(([k1], [k2]) => k1.localeCompare(k2)));
|
||||
return JSON.stringify(normalizedObj1) === JSON.stringify(normalizedObj2);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -77,6 +77,8 @@ en:
|
|||
filter_create_new: "Create"
|
||||
cancel: "Cancel"
|
||||
create: "Create"
|
||||
new_project: "New \"%{name}\" Project"
|
||||
new_experiment: "New \"%{name}\" Experiment"
|
||||
recent_work:
|
||||
title: "Recent work"
|
||||
no_results:
|
||||
|
|
Loading…
Reference in a new issue