Skip to content
Extraits de code Groupes Projets
Valider a668603c rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Add isSubmitting property to piwik-ajax-form directive and make sure child...

Add isSubmitting property to piwik-ajax-form directive and make sure child elements can access scope.
parent ef2e3422
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -28,6 +28,13 @@
*/
vm.errorPostResponse = null;
/**
* true if currently submitting a POST request, false if otherwise.
*
* @type {bool}
*/
vm.isSubmitting = false;
vm.submitForm = submitForm;
/**
......@@ -45,6 +52,7 @@
postParams = vm.data;
}
vm.isSubmitting = true;
piwikApi.post(
{ // GET params
module: 'API',
......@@ -69,6 +77,8 @@
}
}).catch(function (errorMessage) {
vm.errorPostResponse = errorMessage;
})['finally'](function () {
//vm.isSubmitting = false;
});
}
}
......
......@@ -46,7 +46,7 @@
* <h2>My Form</h2>
* <input name="myOption" value="myDefaultValue" type="text" />
* <input name="myOtherOption" type="checkbox" checked="checked" />
* <input type="submit" value="Submit" />
* <input type="submit" value="Submit" ng-disabled="ajaxForm.isSubmitting" />
*
* <div piwik-notification context='error' ng-show="errorPostResponse">ERROR!</div>
* </div>
......@@ -68,6 +68,7 @@
require: '?ngModel',
controller: 'AjaxFormController',
controllerAs: 'ajaxForm',
transclude: true,
compile: function (element, attrs) {
if (!attrs.submitApiMethod) {
throw new Error("submitApiMethod is required");
......@@ -75,7 +76,7 @@
attrs.noErrorNotification = !! attrs.noErrorNotification;
return function (scope, element, attrs, ngModel) {
return function (scope, element, attrs, ngModel, transclude) {
scope.ajaxForm.submitApiMethod = scope.submitApiMethod;
scope.ajaxForm.sendJsonPayload = scope.sendJsonPayload;
scope.ajaxForm.noErrorNotification = scope.noErrorNotification;
......@@ -100,6 +101,11 @@
scope.ajaxForm.submitForm();
});
// make sure child elements can access this directive's scope
transclude(scope, function(clone, scope) {
element.append(clone);
});
function setFormValueFromInput(inputElement) {
var $ = angular.element,
name = $(inputElement).attr('name'),
......
Subproject commit 235d158cb98415144ef5bf6312703c83ff1c9b08
Subproject commit d98325f48a495a6d5d71cb1ffed231f6834f30bb
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter