mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-05 04:03:45 +08:00
Refactor modal loading [SCI-6780]
This commit is contained in:
parent
e06b398bb4
commit
3b60c62c79
12 changed files with 47 additions and 16 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
class StepOrderableElementsController < ApplicationController
|
class StepOrderableElementsController < ApplicationController
|
||||||
before_action :load_vars_nested
|
before_action :load_vars_nested
|
||||||
before_action :load_vars
|
before_action :load_vars, only: :destroy
|
||||||
before_action :check_manage_permissions, only: %i(create destroy)
|
before_action :check_manage_permissions, only: %i(create destroy)
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
export default {
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
confirmingDelete: false
|
||||||
|
};
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showDeleteModal() {
|
showDeleteModal() {
|
||||||
$('#modalDestroyProtocolContent').modal('show');
|
this.confirmingDelete = true;
|
||||||
$('#modalDestroyProtocolContent .delete-step').off().one('click', () => {
|
},
|
||||||
this.deleteComponent();
|
closeDeleteModal() {
|
||||||
$('#modalDestroyProtocolContent').modal('hide');
|
this.confirmingDelete = false;
|
||||||
});
|
|
||||||
},
|
},
|
||||||
deleteComponent() {
|
deleteComponent() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="protocol-modals">
|
<div class="protocol-modals">
|
||||||
<deleteComponentModal/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="modal" id="modalDestroyProtocolContent" tabindex="-1" role="dialog">
|
<div ref="modal" class="modal" id="modalDestroyProtocolContent" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn btn-secondary" data-dismiss="modal">{{ i18n.t('general.cancel') }}</button>
|
<button class="btn btn-secondary" @click="cancel">{{ i18n.t('general.cancel') }}</button>
|
||||||
<button class="btn btn-danger delete-step">Delete forever</button>
|
<button class="btn btn-danger" @click="confirm">{{ i18n.t('protocols.steps.modals.delete_component.confirm')}}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,6 +23,19 @@
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'deleteComponentModal'
|
name: 'deleteComponentModal',
|
||||||
|
mounted() {
|
||||||
|
$(this.$refs.modal).modal('show');
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
confirm() {
|
||||||
|
$(this.$refs.modal).modal('hide');
|
||||||
|
this.$emit('confirm');
|
||||||
|
},
|
||||||
|
cancel() {
|
||||||
|
$(this.$refs.modal).modal('hide');
|
||||||
|
this.$emit('cancel');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -109,10 +109,10 @@
|
||||||
},
|
},
|
||||||
changeState() {
|
changeState() {
|
||||||
this.step.attributes.completed = !this.step.attributes.completed;
|
this.step.attributes.completed = !this.step.attributes.completed;
|
||||||
this.$emit('step:update', this.step)
|
this.$emit('step:update', this.step.attributes)
|
||||||
$.post(this.step.attributes.urls.state_url, {completed: this.step.attributes.completed}).error(() => {
|
$.post(this.step.attributes.urls.state_url, {completed: this.step.attributes.completed}).error(() => {
|
||||||
this.step.attributes.completed = !this.step.attributes.completed;
|
this.step.attributes.completed = !this.step.attributes.completed;
|
||||||
this.$emit('step:update', this.step)
|
this.$emit('step:update', this.step.attributes)
|
||||||
HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger');
|
HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger');
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,13 +4,17 @@
|
||||||
<button class="btn icon-btn btn-light" @click="showDeleteModal">
|
<button class="btn icon-btn btn-light" @click="showDeleteModal">
|
||||||
<i class="fas fa-trash"></i>
|
<i class="fas fa-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
|
<deleteComponentModal v-if="confirmingDelete" @confirm="deleteComponent" @cancel="closeDeleteModal"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import DeleteMixin from 'vue/protocol/mixins/components/delete.js'
|
import DeleteMixin from 'vue/protocol/mixins/components/delete.js'
|
||||||
|
import deleteComponentModal from 'vue/protocol/modals/delete_component.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Checklist',
|
name: 'Checklist',
|
||||||
|
components: { deleteComponentModal },
|
||||||
mixins: [DeleteMixin],
|
mixins: [DeleteMixin],
|
||||||
props: {
|
props: {
|
||||||
element: {
|
element: {
|
||||||
|
|
|
@ -4,13 +4,17 @@
|
||||||
<button class="btn icon-btn btn-light" @click="showDeleteModal">
|
<button class="btn icon-btn btn-light" @click="showDeleteModal">
|
||||||
<i class="fas fa-trash"></i>
|
<i class="fas fa-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
|
<deleteComponentModal v-if="confirmingDelete" @confirm="deleteComponent" @cancel="closeDeleteModal"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import DeleteMixin from 'vue/protocol/mixins/components/delete.js'
|
import DeleteMixin from 'vue/protocol/mixins/components/delete.js'
|
||||||
|
import deleteComponentModal from 'vue/protocol/modals/delete_component.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'StepTable',
|
name: 'StepTable',
|
||||||
|
components: { deleteComponentModal },
|
||||||
mixins: [DeleteMixin],
|
mixins: [DeleteMixin],
|
||||||
props: {
|
props: {
|
||||||
element: {
|
element: {
|
||||||
|
|
|
@ -4,13 +4,17 @@
|
||||||
<button class="btn icon-btn btn-light" @click="showDeleteModal">
|
<button class="btn icon-btn btn-light" @click="showDeleteModal">
|
||||||
<i class="fas fa-trash"></i>
|
<i class="fas fa-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
|
<deleteComponentModal v-if="confirmingDelete" @confirm="deleteComponent" @cancel="closeDeleteModal"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import DeleteMixin from 'vue/protocol/mixins/components/delete.js'
|
import DeleteMixin from 'vue/protocol/mixins/components/delete.js'
|
||||||
|
import deleteComponentModal from 'vue/protocol/modals/delete_component.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'StepText',
|
name: 'StepText',
|
||||||
|
components: { deleteComponentModal },
|
||||||
mixins: [DeleteMixin],
|
mixins: [DeleteMixin],
|
||||||
props: {
|
props: {
|
||||||
element: {
|
element: {
|
||||||
|
|
|
@ -6,7 +6,7 @@ class ChecklistSerializer < ActiveModel::Serializer
|
||||||
attributes :name, :urls
|
attributes :name, :urls
|
||||||
|
|
||||||
def urls
|
def urls
|
||||||
return unless object.step
|
return if object.destroyed?
|
||||||
|
|
||||||
{
|
{
|
||||||
delete_url: step_checklist_path(object.step, object)
|
delete_url: step_checklist_path(object.step, object)
|
||||||
|
|
|
@ -6,7 +6,9 @@ class StepTableSerializer < ActiveModel::Serializer
|
||||||
attributes :name, :urls
|
attributes :name, :urls
|
||||||
|
|
||||||
def urls
|
def urls
|
||||||
return unless object.step
|
return if object.destroyed?
|
||||||
|
|
||||||
|
object.reload unless object.step
|
||||||
|
|
||||||
{
|
{
|
||||||
delete_url: step_table_path(object.step, object)
|
delete_url: step_table_path(object.step, object)
|
||||||
|
|
|
@ -6,7 +6,7 @@ class StepTextSerializer < ActiveModel::Serializer
|
||||||
attributes :text, :urls
|
attributes :text, :urls
|
||||||
|
|
||||||
def urls
|
def urls
|
||||||
return unless object.step
|
return if object.destroyed?
|
||||||
|
|
||||||
{
|
{
|
||||||
delete_url: step_text_path(object.step, object)
|
delete_url: step_text_path(object.step, object)
|
||||||
|
|
|
@ -2528,6 +2528,7 @@ en:
|
||||||
title: 'Delete content'
|
title: 'Delete content'
|
||||||
description_1: 'You’re about to delete a content block from your protocol. It might contain data you don’t want to lose. You won’t be able to get it back.'
|
description_1: 'You’re about to delete a content block from your protocol. It might contain data you don’t want to lose. You won’t be able to get it back.'
|
||||||
description_2: 'Are you sure you want to delete it?'
|
description_2: 'Are you sure you want to delete it?'
|
||||||
|
confirm: 'Delete forever'
|
||||||
options:
|
options:
|
||||||
up_arrow_title: "Move step up"
|
up_arrow_title: "Move step up"
|
||||||
down_arrow_title: "Move step down"
|
down_arrow_title: "Move step down"
|
||||||
|
|
Loading…
Reference in a new issue