From ce3bb9c99a98adac2d0fb5e5f1dca14aa50fa8de Mon Sep 17 00:00:00 2001 From: Armand Bahi <armand.bahi@veremes.com> Date: Wed, 7 Nov 2018 15:46:51 +0100 Subject: [PATCH] =?UTF-8?q?Resolve=20"[Studio]=20suppressions=20des=20diff?= =?UTF-8?q?=C3=A9rents=20formulaires"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../studio/javascript/app/JsonLoader.js | 153 ++++++++++-------- .../externs/studio/lang/lang-en.json | 10 +- .../externs/studio/lang/lang-fr.json | 10 +- .../externs/studio/templates/JsonLoader.html | 22 ++- 4 files changed, 126 insertions(+), 69 deletions(-) diff --git a/client/javascript/externs/studio/javascript/app/JsonLoader.js b/client/javascript/externs/studio/javascript/app/JsonLoader.js index 8dd8de68..ff0407e2 100755 --- a/client/javascript/externs/studio/javascript/app/JsonLoader.js +++ b/client/javascript/externs/studio/javascript/app/JsonLoader.js @@ -248,7 +248,7 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.requestToJson = functi cmd = "Perso_Reset"; break; } - this_.putRequest(cmd, undefined, function (data) { + this_.putRequest(cmd, this_.$scope_["FormSelected"], undefined, function (data) { // Cas d'erreur du put if (goog.isDefAndNotNull(data['errorMessage'])) { @@ -584,18 +584,6 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.save = function (succe oVFB.unselectAll(); tmp = oVFB.cleanFormToSave(tmp); - /*if ($("#boolean-JS-include").prop("checked")) { - tmp[this_.$rootScope_["selected_form_type"]]["javascript"] = true; - } else { - tmp[this_.$rootScope_["selected_form_type"]]["javascript"] = false; - } - - if ($("#boolean-CSS-include").prop("checked")) { - tmp[this_.$rootScope_["selected_form_type"]]["style"] = true; - } else { - tmp[this_.$rootScope_["selected_form_type"]]["style"] = false; - }*/ - if (this['applicationName'] === 'gtf') { tmp[this_.$rootScope_["selected_form_type"]]["name"] = "WSubform"; tmp["display"] = tmp[this_.$rootScope_["selected_form_type"]]; @@ -623,7 +611,7 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.save = function (succe oVFB.valid = this.isValid(tmp); if (oVFB.valid && tmp !== null) { - this_.putRequest("Perso_Save", data, success, error); + this_.putRequest("Perso_Save", this_.$scope_["FormSelected"], data, success, error); } else { $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["Validation_Error"] + ': ' + oVFB.aNotValid, {"className": "error", "autoHideDelay": oVFB.TimeNotify_}); } @@ -646,18 +634,6 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.publish = function () // Supprime les elements selectionnés oVFB.unselectAll(); - /*if ($("#boolean-JS-include").prop("checked")) { - tmp[this_.$rootScope_["selected_form_type"]]["javascript"] = true; - } else { - tmp[this_.$rootScope_["selected_form_type"]]["javascript"] = false; - } - - if ($("#boolean-CSS-include").prop("checked")) { - tmp[this_.$rootScope_["selected_form_type"]]["style"] = true; - } else { - tmp[this_.$rootScope_["selected_form_type"]]["style"] = false; - }*/ - if (this['applicationName'] === 'gtf') { tmp[this_.$rootScope_["selected_form_type"]]["name"] = "WSubform"; tmp["display"] = tmp[this_.$rootScope_["selected_form_type"]]; @@ -669,7 +645,6 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.publish = function () data.append("Css", oVFB.getCss()); var success = function () { -// $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["SaveData"], {"className": "success", "autoHideDelay": oVFB.TimeNotify_}); var data = ""; var success = function () { this_.requestToJson(); @@ -679,17 +654,16 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.publish = function () $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["Publish_Error"] + status, {"className": "error", "autoHideDelay": oVFB.TimeNotify_}); }; - this_.putRequest(this_.$scope_["FormSelected"] + "_Published", data, success, error); + this_.putRequest(this_.$scope_["FormSelected"] + "_Published", this_.$scope_["FormSelected"], data, success, error); }; var error = function (data, status) { $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["SaveData_Error"] + status, {"className": "error", "autoHideDelay": oVFB.TimeNotify_}); }; if (oVFB.valid) { if (this_.$scope_["FormSelected"] != "Default") { - this_.putRequest("Perso_Save", data, success, error); + this_.putRequest("Perso_Save", this_.$scope_["FormSelected"], data, success, error); } else { - this_.putRequest("Default_Published", data, success, error); - + this_.putRequest("Default_Published", this_.$scope_["FormSelected"], data, success, error); } } else { $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["Validation_Error"], {"className": "error", "autoHideDelay": oVFB.TimeNotify_}); @@ -763,7 +737,7 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.reset = function () { var error = function (data, status) { $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["Reset_Error"] + status, {"className": "error", "autoHideDelay": oVFB.TimeNotify_}); }; - this_.putRequest(this_.$scope_["FormSelected"] + "_Reset", data, success, error); + this_.putRequest(this_.$scope_["FormSelected"] + "_Reset", this_.$scope_["FormSelected"], data, success, error); } } }); @@ -771,14 +745,63 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.reset = function () { oVFB.studioMainController.prototype.moveBootboxModalToStudioContainer(oModal); }; +/** + * Remove the published form on the server + * + * @export + */ +nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.deletePublishedForm = function () { + oVFB.log('nsVFB.JsonLoader.jsonLoaderController.deletePublishedForm'); + + var this_ = this; + var oModal = bootbox.confirm('<h4>' + this["text"]["InfoBulle"]["Published"]["DeletePublishedForm"] + ' ?</h4>', function (result) { + if (result === true) { + var data = ""; + var success = function () { + $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["Delete"], {"className": "success", "autoHideDelay": oVFB.TimeNotify_}); + this_.requestToJson(); + }; + var error = function (data, status) { + $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["Delete_Error"] + status, {"className": "error", "autoHideDelay": oVFB.TimeNotify_}); + }; + this_.putRequest('Published_Delete', 'Published', data, success, error); + } + }); +} + +/** + * Remove the form JS on the server + * + * @export + */ +nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.deleteJS = function () { + oVFB.log('nsVFB.JsonLoader.jsonLoaderController.deleteJS'); + + var this_ = this; + var oModal = bootbox.confirm('<h4>' + this["text"]["InfoBulle"]["Perso"]["Delete_JS"] + ' ?</h4>', function (result) { + if (result === true) { + var data = ""; + var success = function () { + $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["Delete_JS"], {"className": "success", "autoHideDelay": oVFB.TimeNotify_}); + this_.requestToJson(); + }; + var error = function (data, status) { + $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["Delete_JS_Error"] + status, {"className": "error", "autoHideDelay": oVFB.TimeNotify_}); + }; + this_.putRequest('Delete_JS', this_.$scope_["FormSelected"], data, success, error); + } + }); +} + /** * Make a put request on the server * @param {string} cmd command to load (Perso_Save, Perso_Published, Default_Published, Perso_Reset etc...) + * @param {string} sForm form to update * @param {object} data FormData to send * @param {function} functSuccess function to load in case of success * @param {function} functError function to load in case of error */ -nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.putRequest = function (cmd, data, functSuccess, functError) { +nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.putRequest = function (cmd, sForm, data, functSuccess, functError) { oVFB.log('nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.putRequest'); var url = ''; @@ -810,15 +833,6 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.putRequest = function 'success': functSuccess, 'error': functError }); - -// this.$http_({ -// url: url, -// method: 'PUT', -// data: data, -// headers: { -// "Content-Type": "undefined" -// } -// }).success(functSuccess).error(functError); }; /** @@ -829,14 +843,34 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.suggestGenerateForm = oVFB.log('nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.suggestGenerateForm'); var this_ = this; - var oModal = bootbox.confirm('<h4>' + this.$scope_['text']['Loader']['Notify']['generate_form'] + '</h4>', function (result) { - if (result === true) { - this_.suggestColumnsToGenerateForm(); - } else { - this_['aSuggestedTableFields'] = []; - this_.generateFormByBusinessObject(); + var oModal = bootbox['dialog']({ + 'message': '<h4>' + this.$scope_['text']['Loader']['Notify']['generate_form'] + '</h4>', + 'buttons': { + 'cancel': { + 'label': this.$scope_['text']['Loader']['Cancel'], + 'className': 'btn-default', + 'callback': function(){ + this_.useEmptyForm(); + } + }, + 'create_empty': { + 'label': this.$scope_['text']['Loader']['CreateEmptyForm'], + 'className': 'btn-primary', + 'callback': function(){ + this_['aSuggestedTableFields'] = []; + this_.generateFormByBusinessObject(); + } + }, + 'generate_from_columns': { + 'label': this.$scope_['text']['Loader']['GenerateForm'], + 'className': 'btn-primary', + 'callback': function(){ + this_.suggestColumnsToGenerateForm(); + } + } } }); + // Déplace la popup dans l'élément principal du studio (sinon elle est masquée en mode plein écran). oVFB.studioMainController.prototype.moveBootboxModalToStudioContainer(oModal); }; @@ -860,10 +894,16 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.useEmptyForm = functio 'javascript': false, 'name': 'custom-form', 'nb_cols': 12, - 'rows': [], + 'rows': [{ + 'fields': [] + }], 'title': '' }; + if (!goog.isArray(data)) { + data = []; + } + data[0] = { 'datasources': {} }; @@ -1017,7 +1057,7 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.generateFormByBusiness var error = function (data, status) { $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["Reset_Error"] + status, {"className": "error", "autoHideDelay": oVFB.TimeNotify_}); }; - this_.putRequest(this_.$scope_["FormSelected"] + "_Reset", {"field": sFieldsToUse, "label": afieldsLabel}, success, error); + this_.putRequest(this_.$scope_["FormSelected"] + "_Reset", this_.$scope_["FormSelected"], {"field": sFieldsToUse, "label": afieldsLabel}, success, error); } else { ajaxRequest({ @@ -1035,19 +1075,6 @@ nsVFB.JsonLoader.prototype.jsonLoaderController.prototype.generateFormByBusiness $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["CreateJson_Error"] + status, {"className": "error", "autoHideDelay": oVFB.TimeNotify_}); } }); - -// this.$http_({ -// url: url, -// method: 'POST', -// data: { -// 'fields': sFieldsToUse, -// 'label': afieldsLabel -// } -// }).success(function () { -// this_.requestToJson(); -// }).error(function () { -// $["notify"](this_.$scope_["text"]["Loader"]["Notify"]["CreateJson_Error"] + status, {"className": "error", "autoHideDelay": oVFB.TimeNotify_}); -// }); } }; diff --git a/client/javascript/externs/studio/lang/lang-en.json b/client/javascript/externs/studio/lang/lang-en.json index f33be9b3..b6d34b37 100755 --- a/client/javascript/externs/studio/lang/lang-en.json +++ b/client/javascript/externs/studio/lang/lang-en.json @@ -10,6 +10,8 @@ "WabState": "State", "Validate": "Validate", "Cancel": "Cancel", + "GenerateForm": "Generate form", + "CreateEmptyForm": "Create empty form", "AddTab": "Add tab", "EditTab": "Edit", "RemoveTab": "Remove", @@ -34,6 +36,7 @@ "Button_gtf": "FME generated form" }, "Published": { + "DeletePublishedForm": "Delete published form", "Button": "Used form", "Button_gtf": "Used form" }, @@ -42,7 +45,8 @@ "Reload": "Reload files from server", "Publish": "Publish the custom form", "Reset": "Replace the custom form by the default form", - "Button": "Modification used form" + "Button": "Modification used form", + "Delete_JS": "Remove JavaScript" } }, "Form": { @@ -87,6 +91,10 @@ "ProblemId": "ID problem, try again or contact an admin", "Reset": "Was reset", "Reset_Error": "Error while resetting : ", + "Delete": "Le formulaire a été supprimé", + "Delete_Error": "Erreur lors de la suppression du formulaire : ", + "Delete_JS": "JavaScript file deleted", + "Delete_JS_Error": "Erorr while deleting JavaScript file : ", "Publish": " Has been published", "PublishAndSave": " Has been published and saved", "Publish_Error": "Error while publishing : ", diff --git a/client/javascript/externs/studio/lang/lang-fr.json b/client/javascript/externs/studio/lang/lang-fr.json index 43a99c1e..ddaad289 100755 --- a/client/javascript/externs/studio/lang/lang-fr.json +++ b/client/javascript/externs/studio/lang/lang-fr.json @@ -10,6 +10,8 @@ "WabState": "État wab", "Validate": "Valider", "Cancel": "Annuler", + "GenerateForm": "Générer un formulaire", + "CreateEmptyForm": "Créer un formulaire vide", "AddTab": "Ajouter un onglet", "EditTab": "Éditer", "RemoveTab": "Supprimer", @@ -34,6 +36,7 @@ "Button_gtf": "Afficher le formulaire par défaut" }, "Published": { + "DeletePublishedForm": "Supprimer le formulaire publié", "Button": "Afficher le formulaire par publié", "Button_gtf": "Afficher le formulaire par publié" }, @@ -44,7 +47,8 @@ "Reset": "Remplacer le formulaire personnalisé par le formulaire par défaut", "ResetWab": "Regénérer le formulaire depuis la base", "Button": "Afficher le formulaire par personnalisé", - "Button_gtf": "Afficher le formulaire par personnalisé" + "Button_gtf": "Afficher le formulaire par personnalisé", + "Delete_JS": "Supprimer la partie JavaScript du formulaire" } }, "Form": { @@ -89,6 +93,10 @@ "ProblemId": "Problème d'ID, réessayer ou contacter un administrateur", "Reset": " a été réinitialisé", "Reset_Error": "Erreur lors de la réinitialisation : ", + "Delete": "Le formulaire a été supprimé", + "Delete_Error": "Erreur lors de la suppression du formulaire : ", + "Delete_JS": "Le fichier JavaScript a été supprimé", + "Delete_JS_Error": "Erreur lors de la suppression du fichier JavaScript : ", "Publish": " a été publié", "PublishAndSave": " a été publié et sauvegardé", "Publish_Error": "Erreur lors de la publication : ", diff --git a/client/javascript/externs/studio/templates/JsonLoader.html b/client/javascript/externs/studio/templates/JsonLoader.html index f5b18f1b..6e320cda 100755 --- a/client/javascript/externs/studio/templates/JsonLoader.html +++ b/client/javascript/externs/studio/templates/JsonLoader.html @@ -1,8 +1,4 @@ <div class="panel panel-veremes" id="FilesURL"> - <!-- <div class="panel-heading unselectable" ng-click="ctrl.resize()">{{::ctrl.text.Title}} - <span ng-if="collapsed" id="colapse_uploader_icon" class="fa fa-angle-right fa-lg" style="float:right"></span> - <span ng-if="!collapsed" id="colapse_uploader_icon" class="fa fa-angle-down fa-lg" style="float:right"></span> - </div>--> <div class="panel-heading unselectable"> <!--Fichier--> <div class="btn-group dropdown margin-right-10"> @@ -50,6 +46,24 @@ {{::ctrl.text.InfoBulle.Perso.Publish}} </a> </li> + <li ng-hide="ctrl.buttonHide" + ng-show="(FormSelected === 'Perso' || FormSelected === 'Published') && ctrl.applicationName === 'vmap'"> + <a title="{{::ctrl.text.InfoBulle.Published.Delete}}" + href="javascript:void(0);" + ng-click="ctrl.deletePublishedForm()"> + <span class="fa icon-trash" aria-hidden="true"></span> + {{::ctrl.text.InfoBulle.Published.DeletePublishedForm}} + </a> + </li> + <li ng-hide="ctrl.buttonHide" + ng-show="(FormSelected === 'Perso' || FormSelected === 'Published') && ctrl.applicationName === 'vmap'"> + <a title="{{::ctrl.text.InfoBulle.Perso.Delete_JS}}" + href="javascript:void(0);" + ng-click="ctrl.deleteJS()"> + <span class="fa icon-trash" aria-hidden="true"></span> + {{::ctrl.text.InfoBulle.Perso.Delete_JS}} + </a> + </li> <li ng-hide="ctrl.buttonHide" ng-show="FormSelected === 'Perso'"> <a title="{{::ctrl.text.InfoBulle.Perso.Reset}}" href="javascript:void(0);" -- GitLab