Skip to content
This repository has been archived by the owner on Dec 23, 2019. It is now read-only.

Commit

Permalink
Merge pull request #561 from ovh-ux/feature/fax/bulkPassword
Browse files Browse the repository at this point in the history
feat(bulk): add bulk action to fax password
  • Loading branch information
Jisay authored Feb 12, 2018
2 parents 3fe5852 + 5dd7d59 commit fc937f6
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module("managerApp").controller("TelecomTelephonyServiceFaxPasswordCtrl", function ($stateParams, $translate, $timeout, TelephonyMediator, OvhApiTelephony, Toast, ToastError) {
angular.module("managerApp").controller("TelecomTelephonyServiceFaxPasswordCtrl", function ($stateParams, $translate, $timeout, TelephonyMediator, OvhApiTelephony, Toast, ToastError, telephonyBulk) {
"use strict";

var self = this;
Expand All @@ -23,7 +23,7 @@ angular.module("managerApp").controller("TelecomTelephonyServiceFaxPasswordCtrl"
self.passwordForm.isSuccess = true;
$timeout(function () {
self.reset();
form.$setPristine();
form.$setUntouched();
}, 3000);
}).catch(function (err) {
Toast.error($translate.instant("telephony_service_fax_password_change_error", { error: _.get(err, "data.message") }));
Expand Down Expand Up @@ -64,5 +64,60 @@ angular.module("managerApp").controller("TelecomTelephonyServiceFaxPasswordCtrl"

/* ----- End of INITIALIZATION ------*/

/* ===========================
= BULK =
============================ */

self.bulkDatas = {
infos: {
name: "faxPassword",
actions: [{
name: "password",
route: "/telephony/{billingAccount}/fax/{serviceName}/settings/changePassword",
method: "POST",
params: null
}]
}
};

self.filterServices = function (services) {
return _.filter(services, function (service) {
return ["fax", "voicefax"].indexOf(service.featureType) > -1;
});
};

self.getBulkParams = function () {
var data = {
password: self.passwordForm.password
};

return data;
};

self.onBulkSuccess = function (bulkResult) {
// display message of success or error
telephonyBulk.getToastInfos(bulkResult, {
fullSuccess: $translate.instant("telephony_service_fax_password_bulk_all_success"),
partialSuccess: $translate.instant("telephony_service_fax_password_bulk_some_success", {
count: bulkResult.success.length
}),
error: $translate.instant("telephony_service_fax_password_bulk_error")
}).forEach(function (toastInfo) {
Toast[toastInfo.type](toastInfo.message, {
hideAfter: null
});
});

// reset initial values to be able to modify again the options
self.reset();
self.faxPasswordForm.$setUntouched();
};

self.onBulkError = function (error) {
Toast.error([$translate.instant("telephony_service_fax_password_bulk_on_error"), _.get(error, "msg.data")].join(" "));
};

/* ----- End of BULK ------ */

init();
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<span data-ng-bind="PasswordCtrl.fax.serviceName | phoneNumber"></span>
</div>

<form name="faxPasswordForm"
data-ng-submit="PasswordCtrl.submitPasswordChange(faxPasswordForm)">
<form name="PasswordCtrl.faxPasswordForm"
data-ng-submit="PasswordCtrl.submitPasswordChange(PasswordCtrl.faxPasswordForm)">

<!-- PASSWORD -->
<div class="form-group"
data-ng-class="{
'has-error': faxPasswordForm.password.$touched && faxPasswordForm.password.$invalid
'has-error': PasswordCtrl.faxPasswordForm.password.$touched && PasswordCtrl.faxPasswordForm.password.$invalid
}">
<label for="password"
data-translate="telephony_service_fax_password_main_title">
Expand All @@ -45,8 +45,8 @@
data-translate-attr="{ placeholder: 'telephony_service_fax_password_main_title' }" />
<span class="help-block"
role="alert"
data-ng-if="faxPasswordForm.password.$touched"
data-ng-messages="faxPasswordForm.password.$error">
data-ng-if="PasswordCtrl.faxPasswordForm.password.$touched"
data-ng-messages="PasswordCtrl.faxPasswordForm.password.$error">
<span data-ng-message="required"
data-translate="telephony_service_fax_password_error_password_required">
</span>
Expand All @@ -62,9 +62,9 @@
<!-- CONFIRM PASSWORD -->
<div class="form-group"
data-ng-class="{
'has-error': faxPasswordForm.confirmPassword.$touched && faxPasswordForm.confirmPassword.$invalid
'has-error': PasswordCtrl.faxPasswordForm.confirmPassword.$touched && PasswordCtrl.faxPasswordForm.confirmPassword.$invalid
}"
data-ng-if="faxPasswordForm.password.$valid">
data-ng-if="PasswordCtrl.faxPasswordForm.password.$valid">
<label for="confirmPassword"
data-translate="telephony_service_fax_password_label_confirm">
</label>
Expand All @@ -79,8 +79,8 @@
data-translate-attr="{ placeholder: 'telephony_service_fax_password_label_confirm' }" />
<span class="help-block"
role="alert"
data-ng-if="faxPasswordForm.confirmPassword.$touched"
data-ng-messages="faxPasswordForm.confirmPassword.$dirty && faxPasswordForm.confirmPassword.$error">
data-ng-if="PasswordCtrl.faxPasswordForm.confirmPassword.$touched"
data-ng-messages="PasswordCtrl.faxPasswordForm.confirmPassword.$dirty && PasswordCtrl.faxPasswordForm.confirmPassword.$error">
<span data-ng-message="passwordMatch"
data-translate="telephony_service_fax_password_error_confirm_password_match">
</span>
Expand All @@ -89,10 +89,21 @@

<!-- SUBMIT -->
<div class="form-group">
<telephony-bulk-action data-billing-account="{{ PasswordCtrl.fax.billingAccount }}"
data-service-name="{{ PasswordCtrl.fax.serviceName }}"
data-custom-class="link d-block pl-0 mb-3"
data-ng-disabled="!PasswordCtrl.faxPasswordForm.$valid"
data-bulk-infos="PasswordCtrl.bulkDatas.infos"
data-filter-services="PasswordCtrl.filterServices"
data-get-bulk-params="PasswordCtrl.getBulkParams"
data-on-success="PasswordCtrl.onBulkSuccess"
data-on-error="PasswordCtrl.onBulkError">
</telephony-bulk-action>

<button
type="submit"
class="btn btn-primary"
data-ng-disabled="faxPasswordForm.$invalid || PasswordCtrl.passwordForm.isUpdating || PasswordCtrl.passwordForm.isSuccess">
data-ng-disabled="PasswordCtrl.faxPasswordForm.$invalid || PasswordCtrl.passwordForm.isUpdating || PasswordCtrl.passwordForm.isSuccess">
<span data-ng-if="PasswordCtrl.passwordForm.isSuccess"
data-translate="telephony_service_fax_password_change_success">
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
<translation id="telephony_service_fax_password_apply" qtlid="249107">Appliquer les modifications</translation>
<translation id="telephony_service_fax_password_change_success" qtlid="337715">Mot de passe modifié avec succès.</translation>
<translation id="telephony_service_fax_password_change_error" qtlid="357239">Impossible de configurer le mot de passe.<br/>{{ error }}</translation>

<translation id="telephony_service_fax_password_bulk_all_success">La modification du mot de passe a bien été appliquée aux services sélectionnés.</translation>
<translation id="telephony_service_fax_password_bulk_some_success">La modification du mot de passe a bien été appliquée à {{ count }} des services sélectionnés.</translation>
<translation id="telephony_service_fax_password_bulk_error">La modification du mot de passe n'a pu être appliquée au(x) service(s) suivant(s) :</translation>
<translation id="telephony_service_fax_password_bulk_on_error">Oups ! Une erreur est survenue lors de la modification du mot de passe .</translation>
</translations>

0 comments on commit fc937f6

Please sign in to comment.