diff --git a/app/javascript/packs/vue/helpers/turbolinks.js b/app/javascript/packs/vue/helpers/turbolinks.js index 259ceb4c8..2367d84d5 100644 --- a/app/javascript/packs/vue/helpers/turbolinks.js +++ b/app/javascript/packs/vue/helpers/turbolinks.js @@ -1,7 +1,9 @@ function mountWithTurbolinks(app, target, callback = null) { const originalHtml = document.querySelector(target).innerHTML; + const cacheDisabled = document.querySelector('#cache-directive'); + const event = cacheDisabled ? 'turbolinks:before-render' : 'turbolinks:before-cache'; - document.addEventListener('turbolinks:before-cache', () => { + document.addEventListener(event, () => { app.unmount(); if (document.querySelector(target)) { document.querySelector(target).innerHTML = originalHtml; diff --git a/app/javascript/packs/vue/legacy/datetime_picker.js b/app/javascript/packs/vue/legacy/datetime_picker.js index 490fec4f5..da4bd84da 100644 --- a/app/javascript/packs/vue/legacy/datetime_picker.js +++ b/app/javascript/packs/vue/legacy/datetime_picker.js @@ -32,6 +32,8 @@ window.initDateTimePickerComponent = (id) => { }, methods: { formatDate(date) { + if (!(date instanceof Date)) return null; + if (this.$refs.input.dataset.simpleFormat) { const y = date.getFullYear(); const m = date.getMonth() + 1; diff --git a/app/javascript/vue/protocol/container.vue b/app/javascript/vue/protocol/container.vue index ade63fb02..1e7d957d3 100644 --- a/app/javascript/vue/protocol/container.vue +++ b/app/javascript/vue/protocol/container.vue @@ -167,6 +167,7 @@ child.step?.id == stepId).uploadFiles(file); + this.$refs.steps.find(child => child.step?.id == stepId).uploadFiles(file); }, firstObjectInViewport() { let step = $('.step-container:not(.locked)').toArray().find(element => { diff --git a/app/javascript/vue/protocol/step.vue b/app/javascript/vue/protocol/step.vue index 4a0806ee8..e143e91f5 100644 --- a/app/javascript/vue/protocol/step.vue +++ b/app/javascript/vue/protocol/step.vue @@ -110,6 +110,7 @@ v-for="(element, index) in orderedElements" :is="elements[index].attributes.orderable_type" :key="element.id" + class="step-element" :element.sync="elements[index]" :inRepository="inRepository" :reorderElementUrl="elements.length > 1 ? urls.reorder_elements_url : ''" @@ -189,7 +190,6 @@ required: false }, activeDragStep: { - type: Number, required: false } }, @@ -507,9 +507,10 @@ HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger'); }).done(() => { this.$parent.$nextTick(() => { - const children = this.$children - const lastChild = children[children.length - 1] - lastChild.$el.scrollIntoView(false) + const children = this.$refs.stepContainer.querySelectorAll(".step-element"); + const lastChild = children[children.length - 1]; + + lastChild.scrollIntoView(false) window.scrollBy({ top: 200, behavior: 'smooth' diff --git a/app/javascript/vue/results/result.vue b/app/javascript/vue/results/result.vue index 4cbd7fd49..ce7c8ff8a 100644 --- a/app/javascript/vue/results/result.vue +++ b/app/javascript/vue/results/result.vue @@ -103,6 +103,7 @@
{ this.$parent.$nextTick(() => { - const children = this.$children - const lastChild = children[children.length - 1] + const children = this.$refs.stepContainer.querySelectorAll(".result-element"); + const lastChild = children[children.length - 1]; lastChild.$el.scrollIntoView(false) window.scrollBy({ top: 200, diff --git a/app/javascript/vue/results/results.vue b/app/javascript/vue/results/results.vue index 520356762..f51eb3240 100644 --- a/app/javascript/vue/results/results.vue +++ b/app/javascript/vue/results/results.vue @@ -18,6 +18,7 @@ />
child.result?.id == resultId).uploadFiles(file); + this.$refs.results.find(child => child.result?.id == resultId).uploadFiles(file); }, firstObjectInViewport() { let result = $('.result-wrapper:not(.locked)').toArray().find(element => { diff --git a/app/javascript/vue/shared/content/mixins/attachments.js b/app/javascript/vue/shared/content/mixins/attachments.js index 728fc43b9..ffe23dd97 100644 --- a/app/javascript/vue/shared/content/mixins/attachments.js +++ b/app/javascript/vue/shared/content/mixins/attachments.js @@ -108,6 +108,10 @@ export default { }, (result) => { fileObject.id = result.data.id; fileObject.attributes = result.data.attributes; + this.attachments.splice(filePosition, 1); + setTimeout(() => { + this.attachments.push(fileObject); + }, 0); }).fail(() => { fileObject.error = I18n.t('attachments.new.general_error'); this.attachments.splice(filePosition, 1); diff --git a/app/javascript/vue/shared/date_time_picker.vue b/app/javascript/vue/shared/date_time_picker.vue index 417a345a4..e5512a51f 100644 --- a/app/javascript/vue/shared/date_time_picker.vue +++ b/app/javascript/vue/shared/date_time_picker.vue @@ -88,18 +88,25 @@ watch: { defaultValue: function () { this.datetime = this.defaultValue; - this.time = { - hours: this.defaultValue ? this.defaultValue.getHours() : 0, - minutes: this.defaultValue ? this.defaultValue.getMinutes() : 0 + if (this.defaultValue) { + this.time = { + hours: this.defaultValue.getHours(), + minutes: this.defaultValue.getMinutes() + } } }, datetime: function () { if (this.mode == 'time') { + this.time = null; + + if (this.datetime) { this.time = { - hours: this.datetime ? this.datetime.getHours() : 0, - minutes: this.datetime ? this.datetime.getMinutes() : 0 + hours: this.datetime.getHours(), + minutes: this.datetime.getMinutes() } + } + return } @@ -131,7 +138,10 @@ newDate.setHours(this.time.hours); newDate.setMinutes(this.time.minutes); } else { - newDate = null; + newDate = { + hours: null, + minutes: null + }; this.$emit('cleared'); } diff --git a/app/javascript/vue/shared/reorderable_items_modal.vue b/app/javascript/vue/shared/reorderable_items_modal.vue index 442e0bb2c..1bcb0c0bd 100644 --- a/app/javascript/vue/shared/reorderable_items_modal.vue +++ b/app/javascript/vue/shared/reorderable_items_modal.vue @@ -22,7 +22,7 @@
-
+
{{ index + 1 }} {{ nameWithFallbacks(element) }} diff --git a/app/views/label_templates/index.html.erb b/app/views/label_templates/index.html.erb index 9f2ac4c16..d0e89d6d3 100644 --- a/app/views/label_templates/index.html.erb +++ b/app/views/label_templates/index.html.erb @@ -1,6 +1,11 @@ <% if current_team %> <% provide(:sidebar_title, t('sidebar.templates.sidebar_title')) %> <% provide(:container_class, "no-second-nav-container") %> + + <% content_for :head do %> + + <% end %> + <%= content_for :sidebar do %> <%= render partial: "/shared/sidebar/templates_sidebar", locals: {active: :label} %> <% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2282e06e2..ffc5f55fe 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,7 +7,6 @@ - <% if user_signed_in? %> @@ -48,10 +47,13 @@ <%= stylesheet_link_tag 'prism' %> <%= csrf_meta_tags %> + + <% if content_for?(:head) %> <%= yield(:head) %> <% end %> + <%= javascript_include_tag 'tui_image_editor' %> <%= stylesheet_link_tag 'tui_image_editor_styles' %> <%= javascript_include_tag 'vue_navigation_navigator' %> diff --git a/app/views/protocols/index.html.erb b/app/views/protocols/index.html.erb index d25bc80b2..aae0fdf1a 100644 --- a/app/views/protocols/index.html.erb +++ b/app/views/protocols/index.html.erb @@ -7,6 +7,10 @@ <% end %> <% provide(:container_class, 'no-second-nav-container') %> + <% content_for :head do %> + + <% end %> +