Fix change org email tab
This commit is contained in:
parent
27a9b84587
commit
805af1c0c0
3 changed files with 25 additions and 23 deletions
|
@ -13,16 +13,20 @@
|
|||
}, ['old-layout']);
|
||||
}]);
|
||||
|
||||
function OrgViewCtrl($scope, $routeParams, $timeout, ApiService, UIService) {
|
||||
function OrgViewCtrl($scope, $routeParams, $timeout, ApiService, UIService, AvatarService) {
|
||||
var orgname = $routeParams.orgname;
|
||||
|
||||
$scope.showLogsCounter = 0;
|
||||
$scope.showApplicationsCounter = 0;
|
||||
$scope.showInvoicesCounter = 0;
|
||||
$scope.changingOrganization = false;
|
||||
|
||||
$scope.$watch('organizationEmail', function(e) {
|
||||
UIService.hidePopover('#changeEmailForm');
|
||||
$scope.orgScope = {
|
||||
'changingOrganization': false,
|
||||
'organizationEmail': ''
|
||||
};
|
||||
|
||||
$scope.$watch('orgScope.organizationEmail', function(e) {
|
||||
UIService.hidePopover('#changeEmailForm input');
|
||||
});
|
||||
|
||||
var loadRepositories = function() {
|
||||
|
@ -41,7 +45,7 @@
|
|||
var loadOrganization = function() {
|
||||
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
||||
$scope.organization = org;
|
||||
$scope.organizationEmail = org.email;
|
||||
$scope.orgScope.organizationEmail = org.email;
|
||||
$scope.isAdmin = org.is_admin;
|
||||
$scope.isMember = org.is_member;
|
||||
|
||||
|
@ -68,24 +72,23 @@
|
|||
};
|
||||
|
||||
$scope.changeEmail = function() {
|
||||
UIService.hidePopover('#changeEmailForm');
|
||||
UIService.hidePopover('#changeEmailForm input');
|
||||
|
||||
$scope.changingOrganization = true;
|
||||
$scope.orgScope.changingOrganization = true;
|
||||
var params = {
|
||||
'orgname': orgname
|
||||
};
|
||||
|
||||
var data = {
|
||||
'email': $scope.organizationEmail
|
||||
'email': $scope.orgScope.organizationEmail
|
||||
};
|
||||
|
||||
ApiService.changeOrganizationDetails(data, params).then(function(org) {
|
||||
$scope.changingOrganization = false;
|
||||
$scope.changeEmailForm.$setPristine();
|
||||
$scope.orgScope.changingOrganization = false;
|
||||
$scope.organization = org;
|
||||
}, function(result) {
|
||||
$scope.changingOrganization = false;
|
||||
UIService.showFormError('#changeEmailForm', result);
|
||||
$scope.orgScope.changingOrganization = false;
|
||||
UIService.showFormError('#changeEmailForm input', result, 'right');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -66,10 +66,10 @@ angular.module('quay').factory('UIService', [function() {
|
|||
}
|
||||
};
|
||||
|
||||
uiService.showPopover = function(elem, content) {
|
||||
uiService.showPopover = function(elem, content, opt_placement) {
|
||||
var popover = $(elem).data('bs.popover');
|
||||
if (!popover) {
|
||||
$(elem).popover({'content': '-', 'placement': 'left'});
|
||||
$(elem).popover({'content': '-', 'placement': opt_placement || 'left'});
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
|
@ -79,10 +79,10 @@ angular.module('quay').factory('UIService', [function() {
|
|||
}, 500);
|
||||
};
|
||||
|
||||
uiService.showFormError = function(elem, result) {
|
||||
uiService.showFormError = function(elem, result, opt_placement) {
|
||||
var message = result.data['message'] || result.data['error_description'] || '';
|
||||
if (message) {
|
||||
uiService.showPopover(elem, message);
|
||||
uiService.showPopover(elem, message, opt_placement);
|
||||
} else {
|
||||
uiService.hidePopover(elem);
|
||||
}
|
||||
|
|
|
@ -105,15 +105,14 @@
|
|||
<h3>Organization Settings</h3>
|
||||
|
||||
|
||||
<div class="panel" ng-show="!changingOrganization">
|
||||
<div class="panel" ng-show="!orgScope.changingOrganization">
|
||||
<div class="panel-title">Organization's e-mail address</div>
|
||||
<div class="panel-content" style="padding-left: 20px; margin-top: 10px;">
|
||||
<form class="form-change" id="changeEmailForm" name="changeEmailForm" ng-submit="changeEmail()" data-trigger="manual"
|
||||
data-content="{{ changeEmailError }}" data-placement="bottom" ng-show="!updatingOrganization">
|
||||
<span class="avatar" size="24" email="organizationEmail" name="orgname"></span>
|
||||
<input type="email" class="form-control" ng-model="organizationEmail"
|
||||
style="margin-left: 10px; margin-right: 10px; width: 400px; display: inline-block;" required>
|
||||
<button class="btn btn-primary" type="submit" ng-disabled="changeEmailForm.$invalid || organizationEmail == organization.email">
|
||||
<form class="form-change" id="changeEmailForm" name="changeEmailForm" ng-submit="changeEmail()">
|
||||
<input type="email" class="form-control" style="max-width: 500px;"
|
||||
ng-model="orgScope.organizationEmail" required>
|
||||
<button class="btn btn-primary" type="submit"
|
||||
ng-disabled="changeEmailForm.$invalid || orgScope.organizationEmail == organization.email">
|
||||
Save
|
||||
</button>
|
||||
</form>
|
||||
|
|
Reference in a new issue