mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge branch 'master' into homepage/rewrite
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
/**
|
||||
* Create a control to show or hide values
|
||||
*
|
||||
*
|
||||
* Possible options are:
|
||||
*
|
||||
*
|
||||
* - froms: an Element, an Array of Element, or a NodeList. A
|
||||
* listener will be attached to **all** input of those elements
|
||||
* and will trigger the check on changes
|
||||
* - test: a function which will test the element and will return true
|
||||
* - test: a function which will test the element and will return true
|
||||
* if the content must be shown, false if it must be hidden.
|
||||
* The function will receive the `froms` as first argument, and the
|
||||
* The function will receive the `froms` as first argument, and the
|
||||
* event as second argument.
|
||||
* - container: an Element, an Array of Element, or a Node List. The
|
||||
* - container: an Element, an Array of Element, or a Node List. The
|
||||
* child nodes will be hidden / shown inside this container
|
||||
* - event_name: the name of the event to listen to. `'change'` by default.
|
||||
*
|
||||
*
|
||||
* @param object options
|
||||
*/
|
||||
var ShowHide = function(options) {
|
||||
@@ -26,8 +26,10 @@ var ShowHide = function(options) {
|
||||
container_content = [],
|
||||
debug = 'debug' in options ? options.debug : false,
|
||||
load_event = 'load_event' in options ? options.load_event : 'load',
|
||||
id = 'uid' in options ? options.id : Math.random();
|
||||
|
||||
id = 'uid' in options ? options.id : Math.random(),
|
||||
toggle_callback = 'toggle_callback' in options ? options.toggle_callback : null
|
||||
;
|
||||
|
||||
var bootstrap = function(event) {
|
||||
if (debug) {
|
||||
console.log('debug is activated on this show-hide', this);
|
||||
@@ -39,15 +41,14 @@ var ShowHide = function(options) {
|
||||
contents.push(el);
|
||||
}
|
||||
container_content.push(contents);
|
||||
// console.log('container content', container_content);
|
||||
}
|
||||
|
||||
// attach the listener on each input
|
||||
for (let f of froms.values()) {
|
||||
let
|
||||
inputs = f.querySelectorAll('input'),
|
||||
let
|
||||
inputs = f.querySelectorAll('input'),
|
||||
selects = f.querySelectorAll('select');
|
||||
|
||||
|
||||
for (let input of inputs.values()) {
|
||||
if (debug) {
|
||||
console.log('attaching event to input', input);
|
||||
@@ -67,10 +68,10 @@ var ShowHide = function(options) {
|
||||
}
|
||||
|
||||
// first launch of the show/hide
|
||||
onChange(event);
|
||||
onChange(event);
|
||||
};
|
||||
|
||||
|
||||
|
||||
var onChange = function (event) {
|
||||
var result = test(froms, event), me;
|
||||
|
||||
@@ -89,45 +90,53 @@ var ShowHide = function(options) {
|
||||
} else {
|
||||
throw "the result of test is not a boolean";
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
var forceHide = function() {
|
||||
if (debug) {
|
||||
console.log('force hide');
|
||||
}
|
||||
for (let contents of container_content.values()) {
|
||||
for (let el of contents.values()) {
|
||||
el.remove();
|
||||
if (toggle_callback !== null) {
|
||||
toggle_callback(container, 'hide');
|
||||
} else {
|
||||
for (let contents of container_content.values()) {
|
||||
for (let el of contents.values()) {
|
||||
el.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
is_shown = false;
|
||||
};
|
||||
|
||||
|
||||
var forceShow = function() {
|
||||
if (debug) {
|
||||
console.log('show');
|
||||
}
|
||||
for (let i of container_content.keys()) {
|
||||
var contents = container_content[i];
|
||||
for (let el of contents.values()) {
|
||||
container[i].appendChild(el);
|
||||
if (toggle_callback !== null) {
|
||||
toggle_callback(container, 'show');
|
||||
} else {
|
||||
for (let i of container_content.keys()) {
|
||||
var contents = container_content[i];
|
||||
for (let el of contents.values()) {
|
||||
container[i].appendChild(el);
|
||||
}
|
||||
}
|
||||
}
|
||||
is_shown = true;
|
||||
};
|
||||
|
||||
|
||||
var forceCompute = function(event) {
|
||||
onChange(event);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
if (load_event !== null) {
|
||||
window.addEventListener('load', bootstrap);
|
||||
} else {
|
||||
bootstrap(null);
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
forceHide: forceHide,
|
||||
forceShow: forceShow,
|
||||
|
@@ -2,29 +2,89 @@ import {ShowHide} from 'ChillMainAssets/lib/show_hide/show_hide.js';
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
let
|
||||
finalizeAfterContainer = document.querySelector('#finalizeAfter'),
|
||||
divTransitions = document.querySelector('#transitions'),
|
||||
futureDestUsersContainer = document.querySelector('#futureDestUsers')
|
||||
;
|
||||
|
||||
if (null === finalizeAfterContainer) {
|
||||
return;
|
||||
}
|
||||
|
||||
new ShowHide({
|
||||
load_event: null,
|
||||
froms: [finalizeAfterContainer],
|
||||
container: [futureDestUsersContainer],
|
||||
test: function(containers, arg2, arg3) {
|
||||
for (let container of containers) {
|
||||
for (let input of container.querySelectorAll('input')) {
|
||||
if (!input.checked) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
if (null !== divTransitions) {
|
||||
new ShowHide({
|
||||
load_event: null,
|
||||
froms: [divTransitions],
|
||||
container: [futureDestUsersContainer],
|
||||
test: function(divs, arg2, arg3) {
|
||||
for (let div of divs) {
|
||||
for (let input of div.querySelectorAll('input')) {
|
||||
if (input.checked) {
|
||||
if (input.dataset.toFinal === "1") {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
})
|
||||
return true;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let
|
||||
transitionFilterContainer = document.querySelector('#transitionFilter'),
|
||||
transitions = document.querySelector('#transitions')
|
||||
;
|
||||
|
||||
if (null !== transitionFilterContainer) {
|
||||
transitions.querySelectorAll('.form-check').forEach(function(row) {
|
||||
|
||||
const isForward = row.querySelector('input').dataset.isForward;
|
||||
|
||||
new ShowHide({
|
||||
load_event: null,
|
||||
froms: [transitionFilterContainer],
|
||||
container: row,
|
||||
test: function (containers) {
|
||||
for (let container of containers) {
|
||||
for (let input of container.querySelectorAll('input')) {
|
||||
if (input.checked) {
|
||||
return isForward === input.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
toggle_callback: function (c, dir) {
|
||||
for (let div of c) {
|
||||
let input = div.querySelector('input');
|
||||
if ('hide' === dir) {
|
||||
input.checked = false;
|
||||
input.disabled = true;
|
||||
} else {
|
||||
input.disabled = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// validate form
|
||||
let form = document.querySelector('form[name="workflow_step"]');
|
||||
|
||||
if (form === null) {
|
||||
console.error('form to validate not found');
|
||||
}
|
||||
|
||||
form.addEventListener('submit', function (event) {
|
||||
const datas = new FormData(event.target);
|
||||
|
||||
if (datas.has('workflow_step[future_dest_users]')) {
|
||||
const dests = JSON.parse(datas.get('workflow_step[future_dest_users]'));
|
||||
if (dests === null || (dests instanceof Array && dests.length === 0)) {
|
||||
event.preventDefault();
|
||||
console.log('no users!');
|
||||
window.alert('Indiquez un utilisateur pour traiter la prochaine étape.');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
|
||||
|
||||
<button v-if="hasWorkflow"
|
||||
class="btn btn-primary"
|
||||
@click="openModal">
|
||||
@@ -7,36 +7,39 @@
|
||||
<template v-if="countWorkflows > 1">{{ $t('workflows') }}</template>
|
||||
<template v-else>{{ $t('workflow') }}</template>
|
||||
</button>
|
||||
|
||||
|
||||
<pick-workflow v-else-if="allowCreate"
|
||||
:relatedEntityClass="this.relatedEntityClass"
|
||||
:relatedEntityId="this.relatedEntityId"
|
||||
:workflowsAvailables="workflowsAvailables"
|
||||
@go-to-generate-workflow="goToGenerateWorkflow"
|
||||
></pick-workflow>
|
||||
|
||||
|
||||
<teleport to="body">
|
||||
<modal v-if="modal.showModal"
|
||||
:modalDialogClass="modal.modalDialogClass"
|
||||
@close="modal.showModal = false">
|
||||
|
||||
|
||||
<template v-slot:header>
|
||||
<h2 class="modal-title">{{ $t('workflow_list') }}</h2>
|
||||
</template>
|
||||
|
||||
|
||||
<template v-slot:body>
|
||||
<list-workflow-vue
|
||||
:workflows="workflows"
|
||||
></list-workflow-vue>
|
||||
</template>
|
||||
|
||||
|
||||
<template v-slot:footer>
|
||||
<pick-workflow v-if="allowCreate"
|
||||
:relatedEntityClass="this.relatedEntityClass"
|
||||
:relatedEntityId="this.relatedEntityId"
|
||||
:workflowsAvailables="workflowsAvailables"
|
||||
:preventDefaultMoveToGenerate="this.$props.preventDefaultMoveToGenerate"
|
||||
@go-to-generate-workflow="this.goToGenerateWorkflow"
|
||||
></pick-workflow>
|
||||
</template>
|
||||
|
||||
|
||||
</modal>
|
||||
</teleport>
|
||||
</template>
|
||||
@@ -53,6 +56,7 @@ export default {
|
||||
PickWorkflow,
|
||||
ListWorkflowVue
|
||||
},
|
||||
emits: ['goToGenerateWorkflow'],
|
||||
props: {
|
||||
workflows: {
|
||||
type: Array,
|
||||
@@ -73,9 +77,14 @@ export default {
|
||||
workflowsAvailables: {
|
||||
type: Array,
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
preventDefaultMoveToGenerate: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
data() {
|
||||
return {
|
||||
modal: {
|
||||
showModal: false,
|
||||
@@ -95,6 +104,10 @@ export default {
|
||||
openModal() {
|
||||
this.modal.showModal = true;
|
||||
},
|
||||
goToGenerateWorkflow(data) {
|
||||
console.log('go to generate workflow intercepted');
|
||||
this.$emit('goToGenerateWorkflow', data);
|
||||
}
|
||||
},
|
||||
i18n: {
|
||||
messages: {
|
||||
@@ -108,4 +121,4 @@ export default {
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
<style scoped></style>
|
||||
|
@@ -6,7 +6,7 @@
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="createWorkflowButton">
|
||||
<li v-for="w in workflowsAvailables" :key="w.name">
|
||||
<a class="dropdown-item" :href="makeLink(w.name)" @click="goToGenerateWorkflow($event, w.name)">{{ w.text }}</a>
|
||||
<a class="dropdown-item" :href="makeLink(w.name)" @click.prevent="goToGenerateWorkflow($event, w.name)">{{ w.text }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -31,7 +31,12 @@ export default {
|
||||
workflowsAvailables: {
|
||||
type: Array,
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
preventDefaultMoveToGenerate: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
emits: ['goToGenerateWorkflow'],
|
||||
methods: {
|
||||
@@ -39,6 +44,12 @@ export default {
|
||||
return buildLinkCreate(workflowName, this.relatedEntityClass, this.relatedEntityId);
|
||||
},
|
||||
goToGenerateWorkflow(event, workflowName) {
|
||||
console.log('goToGenerateWorkflow', event, workflowName);
|
||||
|
||||
if (!this.$props.preventDefaultMoveToGenerate) {
|
||||
event.target.click();
|
||||
}
|
||||
|
||||
this.$emit('goToGenerateWorkflow', {event, workflowName, link: this.makeLink(workflowName)});
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,58 @@
|
||||
{% if transition_form is not null %}
|
||||
{{ form_start(transition_form) }}
|
||||
|
||||
{{ form_row(transition_form.transition) }}
|
||||
{% set step = entity_workflow.currentStepChained %}
|
||||
{% set labels = workflow_metadata(entity_workflow, 'label', step.currentStep) %}
|
||||
{% set label = labels is null ? step.currentStep : labels|localize_translatable_string %}
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{{ 'workflow.Current step'|trans }} :
|
||||
<span class="badge bg-primary">{{ label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if step.previous is not null %}
|
||||
{% if step.previous.comment is not empty %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<blockquote class="chill-user-quote">
|
||||
{{ step.previous.comment|chill_markdown_to_html }}
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{{ 'By'|trans }}
|
||||
{{ step.previous.transitionBy|chill_entity_render_box }},
|
||||
{{ step.previous.transitionAt|format_datetime('short', 'short') }}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="row">
|
||||
<div class="col-sm-4">{{ 'workflow.Created by'|trans }}</div>
|
||||
<div class="col-sm-8">{{ step.entityWorkflow.createdBy|chill_entity_render_box }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-4">{{ 'Le'|trans }}</div>
|
||||
<div class="col-sm-8">{{ step.entityWorkflow.createdAt|format_datetime('short', 'short') }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="transitionFilter">
|
||||
{% if transition_form.transitionFilter is defined %}
|
||||
{{ form_row(transition_form.transitionFilter) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div id="transitions">
|
||||
{{ form_row(transition_form.transition) }}
|
||||
</div>
|
||||
|
||||
{% if transition_form.freezeAfter is defined %}
|
||||
{{ form_row(transition_form.freezeAfter) }}
|
||||
|
@@ -69,6 +69,18 @@
|
||||
</blockquote>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if loop.last and step.destUser|length > 0 %}
|
||||
<div class="item-row separator">
|
||||
<div>
|
||||
<p><b>{{ 'workflow.Users allowed to apply transition'|trans }} : </b></p>
|
||||
<ul>
|
||||
{% for u in step.destUser %}
|
||||
<li>{{ u|chill_entity_render_box }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
|
Reference in New Issue
Block a user