All Downloads are FREE. Search and download functionalities are using the official Maven repository.

static.js.ff4j.js Maven / Gradle / Ivy

There is a newer version: 2.1
Show newest version
// ---------------------
//     VIEW FEATURES
// ---------------------

// Dynamically display a message in any view
function ff4j_displayMessage(msgType, msgInfo) {
	$('#message').html(
	 '
' + '' + '' + msgInfo + '
'); } // Toggle OFF a feature through AXAJ call function ff4j_disable(flip) { $.ajax({ type: 'GET', url: $(location).attr('href'), data : 'op=disable&uid=' + $(flip).attr('id'), dataType : 'html', success : function(code_html, statut){ ff4j_displayMessage("success", "Toggle OFF feature " + $(flip).attr('id') + ""); }, error : function(resultat, statut, erreur){ ff4j_displayMessage("error", statut + "-" + erreur); $(flip).prop('checked', false); }, complete : function(resultat, statut){ console.log("Toggle OFF feature " + $(flip).attr('id') + ""); } }); } // Toggle ON a feature through AXAJ call function ff4j_enable(flip) { $.ajax({ type: 'GET', url: $(location).attr('href'), data : 'op=enable&uid=' + $(flip).attr('id'), dataType : 'html', success : function(code_html, statut){ ff4j_displayMessage("success", "Toggle ON feature " + $(flip).attr('id') + ""); }, error : function(resultat, statut, erreur){ ff4j_displayMessage("error", statut + "-" + erreur); $(flip).prop('checked', false); }, complete : function(resultat, statut){ console.log("Toggle ON feature " + $(flip).attr('id') + ""); } }); } // Triggered by clic, toggle ON/OFF depending on state function toggle(flip) { if(!$(flip).is(':checked')) { ff4j_disable(flip); } else { ff4j_enable(flip); } } function confirmBeforeDeleteFeature(feature) { /* $('button[name="remove_levels"]').on('click', function(e){ var $form=$(this).closest('form'); e.preventDefault(); $('#confirm').modal({ backdrop: 'static', keyboard: false }) .one('click', '#delete', function (e) { $form.trigger('submit'); }); });*/ } // Display Custom Properties for current feature in the table function showCustomProperties(uid) { show('detailCustomP-' + uid); show('linkhideCustomP-' + uid); hide('linkCustomP-' + uid); } // Hide the list of customProperties function hideCustomProperties(uid) { hide('detailCustomP-' + uid); hide('linkhideCustomP-' + uid); show('linkCustomP-' + uid); } // Show target permissions for feature function showFeaturePermissions(uid) { show('detailPerm-' + uid); show('linkhidePerm-' + uid); hide('linkPerm-' + uid); } // Hide target permission function hideFeaturePermissions(uid) { hide('detailPerm-' + uid); hide('linkhidePerm-' + uid); show('linkPerm-' + uid); } // --------------------- // MODAL DELETE FEATURE // --------------------- function ff4j_updateModalDeleteFeature(uid) { console.log("ff4j_updateModalDeleteFeature"); console.log(uid) $("#modalDeleteFeature #uid").val(uid); } function ff4j_updateModalDeleteProperty(uid) { $("#modalDeleteProperty #name").val(uid); } // At Load, fill edit form with Data coming from REST Call function ff4j_updateModalEditFeature(uid) { var modalEdit = $("#modalEdit"); $.get('api/features/' + uid, function(feature) { modalEdit.find("#uid").val(feature.uid); modalEdit.find("#desc").val(feature.description); // Group if (feature.group) { $("#modalEdit #groupName").val(feature.group); } // Strategy if (feature.flippingStrategy) { $("#modalEdit #stratlist").show(); $("#modalEdit #strategy").val(feature.flippingStrategy.type); var initParamsStr = ''; for (var key in feature.flippingStrategy.initParams) { if (feature.flippingStrategy.initParams.hasOwnProperty(key)) { if (initParamsStr.length > 0) { initParamsStr+= ';'; } initParamsStr+= (key + '=' + feature.flippingStrategy.initParams[key]); } } $("#modalEdit #initParams").val(initParamsStr); } else { $("#modalEdit #stratlist").hide(); $("#modalEdit #strategy").val(''); $("#modalEdit #initParams").val(''); } // Permissions ff4j_drawPermissions(feature.uid); // CustomProperties ff4j_drawCustomProperties(feature.uid); }); } // Display the permissions as dynamically changed in modal function ff4j_drawPermissions(uid) { $("#modalEdit #permlist").hide(); $("#modalEdit #permission").val('Public'); $.get('api/features/' + uid, function(feature) { var htmlForFixedValueList = ''; if (feature.permissions) { var permissions = feature.permissions; var arrayLength = permissions.length; if (arrayLength > 0) { $("#modalEdit #permlist").show(); $("#modalEdit #permission").val('Define Permissions'); for (var i = 0; i < arrayLength; i++) { htmlForFixedValueList+= '' + permissions[i] + ''; htmlForFixedValueList+= ''; htmlForFixedValueList+= ''; } } } htmlForFixedValueList+= ''; htmlForFixedValueList+= ' '; htmlForProperties+= ''; htmlForProperties+= ''; htmlForProperties+= ''; htmlForProperties+= ''; } } } htmlForProperties+= ''; htmlForProperties+= ''; htmlForProperties+= '  New Property'; $("#modalEditFeatureProperties").html(htmlForProperties); }); } // Remove a property for a feature function ff4j_removePropertiesForFeature(uid, propName) { $.ajax({ type: 'GET', url: $(location).attr('href'), data : 'op=deleteProperty&uid=' + uid + '&name=' + propName, dataType : 'html', success : function(permissionList, statut) { ff4j_drawCustomProperties(uid); }, error : function(resultat, statut, erreur) { }, complete : function(resultat, statut){ console.log("Delete Custom Properties" + propName); } }); } // <-- //--------------------- // MODAL EDIT PROPERTY //--------------------- // Fill fields from dedicated property function ff4j_updateModalEditProperty(name) { $("#updatePropertyFeatureControlGroup").hide(); var modalEditProperty = $("#modalEditProperty"); $.get('api/properties/' + name, function(myProperty) { modalEditProperty.find("#name").val(myProperty.name); modalEditProperty.find("#pDesc").val(myProperty.description); modalEditProperty.find("#pType").val(myProperty.type); modalEditProperty.find("#pValue").val(myProperty.value); ff4j_drawFixedValues(myProperty.name); }); } function ff4j_drawFixedValues(name) { $("#modalEditPropertyFixedValues").html(''); $.get('api/properties/' + name, function(myProperty) { if (myProperty.fixedValues) { var htmlForValues = '
'; htmlForValues+= ''; htmlForValues+= ''; htmlForValues+= '
'; $("#div-value-property").html(htmlForValues); } else { // no myProperty.fixedValues var htmlForValue = ''; $("#div-value-property").html(htmlForValue); } htmlForFixedValueList+= ''; htmlForFixedValueList+= '  



© 2015 - 2024 Weber Informatics LLC | Privacy Policy