supervisor editing solved #78

parent 62dcf558
/* global angular */ /* global angular */
angular.module('dashboardConfig', []).constant('config', { angular.module('dashboardConfig', []).constant('config', {
backend: 'https://' + window.location.host, backend: 'http://' + window.location.host,
}); });
...@@ -14,11 +14,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor ...@@ -14,11 +14,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
surname: '', surname: '',
address: '', address: '',
country: '', country: '',
postalCode: '',
email: '', email: '',
phone: '', phone: '',
gender: 'F', gender: 'F',
lang: 'es', lang: 'es',
office: '' office: '',
password: '',
password_confirm: ''
}; };
// List of supervisors // List of supervisors
...@@ -53,11 +56,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor ...@@ -53,11 +56,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
surname: '', surname: '',
address: '', address: '',
country: '', country: '',
postalCode: '',
email: '', email: '',
phone: '', phone: '',
gender: 'F', gender: 'F',
lang: 'es', lang: 'es',
office: '' office: '',
password: '',
password_confirm: ''
}; };
// Hide the form // Hide the form
...@@ -78,11 +84,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor ...@@ -78,11 +84,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
name: supervisor.name, name: supervisor.name,
surname: supervisor.surname, surname: supervisor.surname,
address: supervisor.address, address: supervisor.address,
postalCode: supervisor.address,
country: supervisor.country, country: supervisor.country,
email: supervisor.email, email: supervisor.email,
actualEmail: supervisor.email, actualEmail: supervisor.email,
phone: supervisor.phone, phone: supervisor.phone,
gender: supervisor.gender, gender: supervisor.gender,
password: supervisor.password,
password_confirm: supervisor.password_confirm,
lang: supervisor.lang, lang: supervisor.lang,
office: supervisor.office office: supervisor.office
}; };
...@@ -94,7 +103,7 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor ...@@ -94,7 +103,7 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
// Checking new email // Checking new email
// If no change, it is deleted from supervisor object // If no change, it is deleted from supervisor object
if(supervisor.email == supervisor.actualEmail){ if (supervisor.email == supervisor.actualEmail){
delete supervisor.email; delete supervisor.email;
delete supervisor.actualEmail; delete supervisor.actualEmail;
} }
...@@ -103,6 +112,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor ...@@ -103,6 +112,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
var supid = supervisor.id; var supid = supervisor.id;
delete supervisor.id; delete supervisor.id;
if (supervisor.password != supervisor.password_confirm)
return;
if (supervisor.password.length == 0) {
delete supervisor.password;
delete supervisor.password_confirm;
}
$http $http
.put(config.backend + '/sup/' + supid, supervisor) .put(config.backend + '/sup/' + supid, supervisor)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
...@@ -122,6 +139,9 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor ...@@ -122,6 +139,9 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
$scope.supervisors[i].gender = data.gender; $scope.supervisors[i].gender = data.gender;
$scope.supervisors[i].lang = data.lang; $scope.supervisors[i].lang = data.lang;
$scope.supervisors[i].office = data.office; $scope.supervisors[i].office = data.office;
$scope.supervisors[i].postalCode = data.postalCode;
$scope.supervisors[i].password = '';
$scope.supervisors[i].password_confirm = '';
} }
} }
...@@ -142,7 +162,13 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor ...@@ -142,7 +162,13 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
var supervisor = $scope.formdatasupervisor; var supervisor = $scope.formdatasupervisor;
// Add password // Add password
supervisor.password = supervisor.name + supervisor.email; if (supervisor.password != supervisor.password_confirm)
return;
if (supervisor.password.length == 0) {
delete supervisor.password;
delete supervisor.password_confirm;
}
$http $http
.post(config.backend+'/sup', supervisor) .post(config.backend+'/sup', supervisor)
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" id="supervisor_postal_code" placeholder="{{ 'postal_code' | translate }}" required ng-model="formdata.postal_code" ng-change="formdata.postal_code = formdata.postal_code.toUpperCase()"/>
</div>
<div class="form-group">
<label translate>country</label> <label translate>country</label>
<select class="form-control" name="supervisor_country" id="supervisor_country" ng-model="formdatasupervisor.country" required> <select class="form-control" name="supervisor_country" id="supervisor_country" ng-model="formdatasupervisor.country" required>
<option value="ES" selected>España</option> <option value="ES" selected>España</option>
...@@ -39,7 +43,7 @@ ...@@ -39,7 +43,7 @@
</div> </div>
<fieldset> <fieldset>
<legend translate>office</legend> <label translate>office</label>
<div class="form-group"> <div class="form-group">
<select class="form-control" name="supervisor_office" id="supervisor_office" ng-model="formdatasupervisor.office" required> <select class="form-control" name="supervisor_office" id="supervisor_office" ng-model="formdatasupervisor.office" required>
<option ng-repeat="of in offices | orderBy: 'name'" value="{{ of.id }}"> <option ng-repeat="of in offices | orderBy: 'name'" value="{{ of.id }}">
...@@ -50,7 +54,7 @@ ...@@ -50,7 +54,7 @@
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend translate>language</legend> <label translate>language</label>
<div class="form-group"> <div class="form-group">
<select class="form-control" name="supervisor_language" id="supervisor_language" ng-model="formdatasupervisor.lang"> <select class="form-control" name="supervisor_language" id="supervisor_language" ng-model="formdatasupervisor.lang">
<option value="es" selected>Español</option> <option value="es" selected>Español</option>
...@@ -59,6 +63,17 @@ ...@@ -59,6 +63,17 @@
</div> </div>
</fieldset> </fieldset>
<fieldset>
<label translate>password</label>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<div class="form-group">
<input type="password" class="form-control" id="supervisor_password1" placeholder="{{ 'password_type' | translate }}" required ng-model="formdatasupervisor.password" />
</div>
<div class="form-group">
<input type="password" class="form-control" id="supervisor_password2" placeholder="{{ 'password_confirm' | translate }}" required ng-model="formdatasupervisor.password_confirm" />
</div>
</fieldset>
<div class="form-group"> <div class="form-group">
<button type="button" class="btn btn-default" ng-click="resetForm()">{{'cancel'|translate}}</button> <button type="button" class="btn btn-default" ng-click="resetForm()">{{'cancel'|translate}}</button>
<button type="submit" class="btn btn-primary" translate>add</button> <button type="submit" class="btn btn-primary" translate>add</button>
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" id="supervisor_postal_code" placeholder="{{ 'postal_code' | translate }}" required ng-model="formdata.postalCode" ng-change="formdata.postalCode = formdata.postalCode.toUpperCase()"/>
</div>
<div class="form-group">
<input type="text" class="form-control" id="supervisor_country" placeholder="{{ 'country' | translate }}" ng-model="formdatasupervisor.country" /> <input type="text" class="form-control" id="supervisor_country" placeholder="{{ 'country' | translate }}" ng-model="formdatasupervisor.country" />
</div> </div>
...@@ -34,7 +38,7 @@ ...@@ -34,7 +38,7 @@
</div> </div>
<fieldset> <fieldset>
<legend translate>office</legend> <label translate>office</label>
<div class="form-group"> <div class="form-group">
<select class="form-control" name="supervisor_office" id="supervisor_office" ng-model="formdatasupervisor.office"> <select class="form-control" name="supervisor_office" id="supervisor_office" ng-model="formdatasupervisor.office">
<option ng-repeat="of in offices | orderBy: 'name'" value="{{ of.id }}"> <option ng-repeat="of in offices | orderBy: 'name'" value="{{ of.id }}">
...@@ -45,7 +49,7 @@ ...@@ -45,7 +49,7 @@
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend translate>language</legend> <label translate>language</label>
<div class="form-group"> <div class="form-group">
<select class="form-control" name="supervisor_language" id="supervisor_language" ng-model="formdatasupervisor.lang"> <select class="form-control" name="supervisor_language" id="supervisor_language" ng-model="formdatasupervisor.lang">
<option value="es">Español</option> <option value="es">Español</option>
...@@ -54,6 +58,17 @@ ...@@ -54,6 +58,17 @@
</div> </div>
</fieldset> </fieldset>
<fieldset>
<label translate>password</label>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<div class="form-group">
<input type="password" class="form-control" id="supervisor_password1" placeholder="{{ 'password_type' | translate }}" ng-model="formdatasupervisor.password" />
</div>
<div class="form-group">
<input type="password" class="form-control" id="supervisor_password2" placeholder="{{ 'password_confirm' | translate }}" ng-model="formdatasupervisor.password_confirm" />
</div>
</fieldset>
<div class="form-group"> <div class="form-group">
<button type="button" class="btn btn-default" ng-click="resetForm()">{{'cancel'|translate}}</button> <button type="button" class="btn btn-default" ng-click="resetForm()">{{'cancel'|translate}}</button>
<button type="submit" class="btn btn-primary" translate>save</button> <button type="submit" class="btn btn-primary" translate>save</button>
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
</div> </div>
</div> </div>
</div> </div>
<fieldset> </fieldset>
<fieldset> <fieldset>
<div class="form-group"> <div class="form-group">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment