Merge pull request #7634 from aignatov-bio/ai-sci-10261-make-protocol-toolbar-responsive

Make protocol toolbar responsive [SCI-10261]
This commit is contained in:
aignatov-bio 2024-06-19 17:14:16 +02:00 committed by GitHub
commit 57b39d81a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 7 deletions

View file

@ -27,20 +27,22 @@
<div class="actions-block"> <div class="actions-block">
<div class="protocol-buttons-group shrink-0 bg-sn-white"> <div class="protocol-buttons-group shrink-0 bg-sn-white">
<a v-if="urls.add_step_url" <a v-if="urls.add_step_url"
class="btn btn-secondary" class="btn btn-secondary icon-btn xl:!px-4"
:title="i18n.t('protocols.steps.new_step_title')" :title="i18n.t('protocols.steps.new_step_title')"
@keyup.enter="addStep(steps.length)" @keyup.enter="addStep(steps.length)"
@click="addStep(steps.length)" @click="addStep(steps.length)"
tabindex="0"> tabindex="0">
<span class="sn-icon sn-icon-new-task" aria-hidden="true"></span> <span class="sn-icon sn-icon-new-task" aria-hidden="true"></span>
<span>{{ i18n.t("protocols.steps.new_step") }}</span> <span class="tw-hidden xl:inline">{{ i18n.t("protocols.steps.new_step") }}</span>
</a> </a>
<template v-if="steps.length > 0"> <template v-if="steps.length > 0">
<button class="btn btn-secondary" @click="collapseSteps" tabindex="0"> <button :title="i18n.t('protocols.steps.collapse_label')" v-if="!stepCollapsed" class="btn btn-secondary icon-btn xl:!px-4" @click="collapseSteps" tabindex="0">
{{ i18n.t("protocols.steps.collapse_label") }} <i class="sn-icon sn-icon-collapse-all"></i>
<span class="tw-hidden xl:inline">{{ i18n.t("protocols.steps.collapse_label") }}</span>
</button> </button>
<button class="btn btn-secondary" @click="expandSteps" tabindex="0"> <button v-else :title="i18n.t('protocols.steps.expand_label')" class="btn btn-secondary icon-btn xl:!px-4" @click="expandSteps" tabindex="0">
{{ i18n.t("protocols.steps.expand_label") }} <i class="sn-icon sn-icon-expand-all"></i>
<span class="tw-hidden xl:inline">{{ i18n.t("protocols.steps.expand_label") }}</span>
</button> </button>
</template> </template>
<ProtocolOptions <ProtocolOptions
@ -154,9 +156,11 @@
</a> </a>
<div v-if="steps.length > 0" class="flex justify-between items-center gap-4"> <div v-if="steps.length > 0" class="flex justify-between items-center gap-4">
<button @click="collapseSteps" class="btn btn-secondary flex px-4" tabindex="0" data-e2e="e2e-BT-protocol-templateSteps-collapse"> <button @click="collapseSteps" class="btn btn-secondary flex px-4" tabindex="0" data-e2e="e2e-BT-protocol-templateSteps-collapse">
<i class="sn-icon sn-icon-collapse-all"></i>
{{ i18n.t("protocols.steps.collapse_label") }} {{ i18n.t("protocols.steps.collapse_label") }}
</button> </button>
<button @click="expandSteps" class="btn btn-secondary flex px-4" tabindex="0" data-e2e="e2e-BT-protocol-templateSteps-expand"> <button @click="expandSteps" class="btn btn-secondary flex px-4" tabindex="0" data-e2e="e2e-BT-protocol-templateSteps-expand">
<i class="sn-icon sn-icon-expand-all"></i>
{{ i18n.t("protocols.steps.expand_label") }} {{ i18n.t("protocols.steps.expand_label") }}
</button> </button>
<a v-if="steps.length > 0 && urls.reorder_steps_url" <a v-if="steps.length > 0 && urls.reorder_steps_url"
@ -192,6 +196,7 @@
@step:attachemnts:loaded="stepToReload = null" @step:attachemnts:loaded="stepToReload = null"
@step:move_attachment="reloadStep" @step:move_attachment="reloadStep"
@step:drag_enter="dragEnter" @step:drag_enter="dragEnter"
@step:collapsed="checkStepsState"
:reorderStepUrl="steps.length > 1 ? urls.reorder_steps_url : null" :reorderStepUrl="steps.length > 1 ? urls.reorder_steps_url : null"
:userSettingsUrl="userSettingsUrl" :userSettingsUrl="userSettingsUrl"
:assignableMyModuleId="protocol.attributes.assignable_my_module_id" :assignableMyModuleId="protocol.attributes.assignable_my_module_id"
@ -290,7 +295,8 @@ export default {
publishing: false, publishing: false,
stepToReload: null, stepToReload: null,
activeDragStep: null, activeDragStep: null,
userSettingsUrl: null userSettingsUrl: null,
stepCollapsed: false
}; };
}, },
mounted() { mounted() {
@ -321,13 +327,20 @@ export default {
reloadStep(step) { reloadStep(step) {
this.stepToReload = step; this.stepToReload = step;
}, },
checkStepsState() {
this.stepCollapsed = this.$refs.steps.every((step) => step.isCollapsed);
},
collapseSteps() { collapseSteps() {
$('.step-container .collapse').collapse('hide'); $('.step-container .collapse').collapse('hide');
this.updateStepStateSettings(true); this.updateStepStateSettings(true);
this.$refs.steps.forEach((step) => step.isCollapsed = true);
this.stepCollapsed = true;
}, },
expandSteps() { expandSteps() {
$('.step-container .collapse').collapse('show'); $('.step-container .collapse').collapse('show');
this.updateStepStateSettings(false); this.updateStepStateSettings(false);
this.$refs.steps.forEach((step) => step.isCollapsed = false);
this.stepCollapsed = false;
}, },
updateStepStateSettings(newState) { updateStepStateSettings(newState) {
const updatedData = this.steps.reduce((acc, currentStep) => { const updatedData = this.steps.reduce((acc, currentStep) => {

View file

@ -293,6 +293,7 @@
} else { } else {
$(stepId).collapse('show'); $(stepId).collapse('show');
} }
this.$emit('step:collapsed');
}); });
$(this.$refs.comments).data('closeCallback', this.closeCommentsSidebar); $(this.$refs.comments).data('closeCallback', this.closeCommentsSidebar);
$(this.$refs.comments).data('openCallback', this.closeCommentsSidebar); $(this.$refs.comments).data('openCallback', this.closeCommentsSidebar);
@ -465,6 +466,7 @@
data: { [this.step.id]: this.isCollapsed } data: { [this.step.id]: this.isCollapsed }
}; };
this.$emit('step:collapsed');
axios.put(this.userSettingsUrl, { settings: [settings] }); axios.put(this.userSettingsUrl, { settings: [settings] });
}, },
showDeleteModal() { showDeleteModal() {