Commit 86db5220 authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

openFormPlayer - добавлена кнопка активации если маршрут по документу не запущен

parent 16c4792a
const getContentFromForm = async (uuid, parentContainer) => { const getContentFromForm = async (uuid, run, parentContainer) => {
const container = $('<div>', {style: 'width: 100%; overflow: hidden;'}); const container = $('<div>', {style: 'width: 100%; overflow: hidden;'});
if(parentContainer) { if(parentContainer) {
container.css('height', '100%'); container.css('height', '100%');
...@@ -13,7 +13,12 @@ const getContentFromForm = async (uuid, parentContainer) => { ...@@ -13,7 +13,12 @@ const getContentFromForm = async (uuid, parentContainer) => {
const buttonSave = $('<span class="material-icons wf-icons" style="display: none;">save</span>'); const buttonSave = $('<span class="material-icons wf-icons" style="display: none;">save</span>');
const buttonPrint = $('<span class="material-icons wf-icons">print</span>'); const buttonPrint = $('<span class="material-icons wf-icons">print</span>');
const buttonEditable = $('<span class="material-icons wf-icons">edit</span>'); const buttonEditable = $('<span class="material-icons wf-icons">edit</span>');
const buttonActivate = $('<button>', {class: "uk-button uk-button-primary uk-button-small uk-hidden"});
if(run) {
buttonActivate.text(run.label);
buttonActivate.removeClass('uk-hidden');
}
player.view.container.css({'background': '#fff'}); player.view.container.css({'background': '#fff'});
playerContainer.append(player.view.container); playerContainer.append(player.view.container);
...@@ -27,7 +32,34 @@ const getContentFromForm = async (uuid, parentContainer) => { ...@@ -27,7 +32,34 @@ const getContentFromForm = async (uuid, parentContainer) => {
} else { } else {
player.saveFormData(result => { player.saveFormData(result => {
showMessage(i18n.tr('Данные сохранены'), 'success'); showMessage(i18n.tr('Данные сохранены'), 'success');
appAPI.modifyDoc(player.model.asfDataId); if(!run) appAPI.modifyDoc(player.model.asfDataId);
Cons.hideLoader();
});
}
});
buttonActivate.on('click', e => {
Cons.showLoader();
if(!player.model.isValid()) {
showMessage(i18n.tr('Заполните обязательные поля'), 'error');
Cons.hideLoader();
} else {
player.saveFormData(async result => {
await appAPI.activateDoc(player.model.asfDataId);
showMessage(i18n.tr('Данные сохранены'), 'success');
editable = false;
player.view.setEditable(editable);
buttonEditable.text('edit');
buttonPrint.show();
if(player.model.hasChanges) {
buttonSave.show();
} else {
buttonSave.hide();
}
buttonActivate.addClass('uk-hidden');
Cons.hideLoader(); Cons.hideLoader();
}); });
} }
...@@ -60,7 +92,7 @@ const getContentFromForm = async (uuid, parentContainer) => { ...@@ -60,7 +92,7 @@ const getContentFromForm = async (uuid, parentContainer) => {
}); });
buttonsPanel.append( buttonsPanel.append(
$('<div>').append(buttonSave, buttonPrint), $('<div>').append(buttonSave, buttonPrint, buttonActivate),
$('<div>').append(buttonEditable) $('<div>').append(buttonEditable)
); );
...@@ -70,8 +102,12 @@ const getContentFromForm = async (uuid, parentContainer) => { ...@@ -70,8 +102,12 @@ const getContentFromForm = async (uuid, parentContainer) => {
this.openFormPlayer = async (uuid, parentContainer = null, closeDialogHandler) => { this.openFormPlayer = async (uuid, parentContainer = null, closeDialogHandler) => {
Cons.showLoader(); Cons.showLoader();
const {container: body, player} = await getContentFromForm(uuid, parentContainer); const documentID = await AS.FORMS.ApiUtils.getDocumentIdentifier(uuid);
const docActions = await AS.FORMS.ApiUtils.simpleAsyncGet(`rest/api/docflow/document_actions?documentID=${documentID}&locale=${AS.OPTIONS.locale}`);
const run = docActions.find(x => x.operation == 'RUN');
const meaning = await appAPI.getDocMeaningContent(uuid) || 'Документ'; const meaning = await appAPI.getDocMeaningContent(uuid) || 'Документ';
const {container: body, player} = await getContentFromForm(uuid, run, parentContainer);
if(parentContainer) { if(parentContainer) {
parentContainer.empty(); parentContainer.empty();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment