Merge pull request #6670 from aignatov-bio/ai-sci-9733-fix-vue3-upgrade-issues

Vue3 migration fixes [SCI-9733][SCI-9735][SCI-9736][SCI-9738]
This commit is contained in:
aignatov-bio 2023-11-20 11:55:30 +01:00 committed by GitHub
commit 26c726789c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 66 additions and 17 deletions

View file

@ -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;

View file

@ -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;

View file

@ -167,6 +167,7 @@
<i class="sn-icon sn-icon-new-task"></i>
</div>
<Step
ref="steps"
:step.sync="steps[index]"
@reorder="startStepReorder"
:inRepository="inRepository"
@ -451,7 +452,7 @@
this.activeDragStep = id;
},
uploadFilesToStep(file, stepId) {
this.$children.find(child => 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 => {

View file

@ -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'

View file

@ -103,6 +103,7 @@
<div v-for="(element, index) in orderedElements" :key="element.id">
<component
:is="elements[index].attributes.orderable_type"
class="result-element"
:element.sync="elements[index]"
:inRepository="false"
:reorderElementUrl="elements.length > 1 ? urls.reorder_elements_url : ''"
@ -433,8 +434,8 @@
HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger');
}).done(() => {
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,

View file

@ -18,6 +18,7 @@
/>
<div class="results-list">
<Result v-for="result in results" :key="result.id"
ref="results"
:result="result"
:resultToReload="resultToReload"
:activeDragResult="activeDragResult"
@ -149,7 +150,7 @@
this.activeDragResult = id;
},
uploadFilesToResult(file, resultId) {
this.$children.find(child => 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 => {

View file

@ -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);

View file

@ -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');
}

View file

@ -22,7 +22,7 @@
<div class="step-element-grip step-element-grip--draggable">
<i class="sn-icon sn-icon-drag"></i>
</div>
<div class="step-element-name text-center">
<div class="step-element-name text-center flex items-center gap-2">
<strong v-if="includeNumbers" class="step-element-number">{{ index + 1 }}</strong>
<i v-if="element.attributes.icon" class="fas" :class="element.attributes.icon"></i>
<span :title="nameWithFallbacks(element)" v-if="nameWithFallbacks(element)">{{ nameWithFallbacks(element) }}</span>

View file

@ -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 %>
<meta id="cache-directive" name="turbolinks-cache-control" content="no-cache">
<% end %>
<%= content_for :sidebar do %>
<%= render partial: "/shared/sidebar/templates_sidebar", locals: {active: :label} %>
<% end %>

View file

@ -7,7 +7,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="max-file-size" content="<%= Rails.configuration.x.file_max_size_mb %>">
<meta name="tiny-mce-assets-url" content="<%= tiny_mce_assets_path %>">
<meta name="turbolinks-cache-control" content="no-preview">
<% if user_signed_in? %>
<meta name="expiration-url" content="<%= users_expire_in_path %>">
<meta name="revive-url" content="<%= users_revive_session_path %>">
@ -48,10 +47,13 @@
<%= stylesheet_link_tag 'prism' %>
<%= csrf_meta_tags %>
<meta id="preview-directive" name="turbolinks-cache-control" content="no-preview">
<% 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' %>

View file

@ -7,6 +7,10 @@
<% end %>
<% provide(:container_class, 'no-second-nav-container') %>
<% content_for :head do %>
<meta id="cache-directive" name="turbolinks-cache-control" content="no-cache">
<% end %>
<div class="content-pane flexible protocols-index <%= @type %>">
<div class="content-header sticky-header">
<div class="title-row">

View file

@ -4,6 +4,10 @@
<%= hidden_field_tag :show_report_preview, nil, class: "file-preview-link", data: { preview_url: document_preview_report_path(params[:preview_report_id], report_type: params[:preview_type]) } %>
<% end %>
<% content_for :head do %>
<meta id="cache-directive" name="turbolinks-cache-control" content="no-cache">
<% end %>
<div class="content-pane flexible reports-index">
<%= render partial: 'reports/index_header' %>
<div id="content-reports-index">

View file

@ -4,6 +4,10 @@
<% provide(:sidebar_url, sidebar_repositories_path) %>
<% provide(:sidebar_title, t('sidebar.repositories.sidebar_title')) %>
<% content_for :head do %>
<meta id="cache-directive" name="turbolinks-cache-control" content="no-cache">
<% end %>
<div class="content-pane repository-show <%= @repository.archived? || params[:archived] ? "archived" : "active" %>" data-table-url="<%= load_table_repository_path(@repository) %>">
<div id="repository-toolbar" class="content-header">
<div class="title-row">

View file

@ -2,6 +2,10 @@
<% provide(:head_title, t("users.settings.teams.head_title")) %>
<% provide(:container_class, "no-second-nav-container") %>
<% content_for :head do %>
<meta id="cache-directive" name="turbolinks-cache-control" content="no-cache">
<% end %>
<%= render partial: "users/settings/sidebar" %>
<div class="tab-content">
<div class="tab-pane content-pane" role="tabpanel"></div>

View file

@ -1,6 +1,10 @@
<% provide(:head_title, t("users.settings.teams.head_title")) %>
<% provide(:container_class, "no-second-nav-container") %>
<% content_for :head do %>
<meta id="cache-directive" name="turbolinks-cache-control" content="no-cache">
<% end %>
<div data-hook="team-beginning"></div>
<%= render partial: "users/settings/sidebar" %>