Skip to content

Instantly share code, notes, and snippets.

@Johan-ZeLearner
Created May 4, 2015 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Johan-ZeLearner/079b933d8f3ad76f9527 to your computer and use it in GitHub Desktop.
Save Johan-ZeLearner/079b933d8f3ad76f9527 to your computer and use it in GitHub Desktop.
<form ng-submit="saveItem(customer_profile)" method="post" class="smart-form" novalidate="novalidate">
<header>Edition : profil client</header>
<fieldset>
<div class="row">
<section>
<label class="label">Nom</label>
<label class="input">
<i class="icon-append fa fa-user"></i>
<input placeholder="Indiquez le nom du profil client" type="text" ng-model="customer_profile.name">
</label>
</section>
</div>
<div class="row">
<section>
<label class="label">Id sur la boutique</label>
<label class="input">
<i class="icon-append fa fa-tag"></i>
<input type="text" placeholder="Indiquez l'id du profil sur la boutique prestashop" ng-model="customer_profile.id_on_store">
</label>
</section>
</div>
<section>
<label class="checkbox"><input type="checkbox" ng-model="customer_profile.visible"><i></i> Groupe visible dans Erpedia</label>
</section>
</fieldset>
<footer>
<button type="submit" class="btn btn-primary">Valider</button>
<a ui-sref="customerProfile.list" class="btn btn-warning">Annuler</a>
</footer>
</form>
(function () {
angular.module('erpedia-customer-profile')
.directive('customerProfileForm', ['CustomerProfile', '$state', function (CustomerProfile, $state) {
return {
restrict: 'E',
replace: true,
scope: {
'id_customer_profile': '=idcustomerprofile'
},
templateUrl: jsBaseHref + '/templates/directives/customerProfileForm.html',
link: function (scope, element, attr) {
var id_customer_profile = scope.id_customer_profile;
scope.customer_profile = CustomerProfile.get({id: id_customer_profile});
},
controller: function ($scope) {
$scope.customer_profile = {name: '...chargement', id_on_store: '... chargement'};
$scope.saveItem = function (item) {
CustomerProfile.save(item, function (results) {
if (results.success === true) {
success('Enregistrement de <strong>' + results.name + ' effectué avec succès</strong>');
$state.go('customerProfile.list');
}
else {
alert('Echec lors de l\'enregistrement du profil');
}
});
};
}
};
}]);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment