JSCS/eslint cleanup - o_s/tech-debt, bind-scope, toast
Following John Papa's Angular style guide https://github.com/johnpapa/angular-styleguide, this patch refactors the openstack_dashboard/../tech-debt files, bind-scope and toast directives. Change-Id: I4ee6a1de87f95630b5b612dcaa0e049cd3c0691a Partially-Implements: blueprint jscs-cleanup
This commit is contained in:
parent
6470157efe
commit
f21ac23909
@ -15,8 +15,12 @@
|
||||
beforeEach(module('horizon.framework.util.bind-scope'));
|
||||
|
||||
beforeEach(module('horizon.framework.util.bind-scope', function ($compileProvider) {
|
||||
$compileProvider.directive('testBindScope', function () {
|
||||
return {
|
||||
/* eslint-disable angular/ng_module_getter */
|
||||
$compileProvider.directive('testBindScope', testBindScope);
|
||||
/* eslint-enable angular/ng_module_getter */
|
||||
|
||||
function testBindScope() {
|
||||
var directive = {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
itemList: '='
|
||||
@ -26,7 +30,8 @@
|
||||
' <span bind-scope-target></span>' +
|
||||
'</li></ul>'
|
||||
};
|
||||
});
|
||||
return directive;
|
||||
}
|
||||
}));
|
||||
|
||||
beforeEach(inject(function ($injector) {
|
||||
@ -44,7 +49,7 @@
|
||||
$element = angular.element(markup);
|
||||
$compile($element)($scope);
|
||||
|
||||
$scope.$digest();
|
||||
$scope.$apply();
|
||||
}));
|
||||
|
||||
it('should have 3 list items', function () {
|
||||
|
@ -116,7 +116,7 @@
|
||||
|
||||
var markup = '<toast></toast>';
|
||||
$element = $compile(markup)($scope);
|
||||
$scope.$digest();
|
||||
$scope.$apply();
|
||||
}));
|
||||
|
||||
it('should create toasts using ng-repeat', function() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "horizon/common/_modal_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block ng_controller %}ImageFormCtrl{% endblock %}
|
||||
{% block ng_controller %}ImageFormController as ctrl{% endblock %}
|
||||
{% block form_attrs %}enctype="multipart/form-data"{% endblock %}
|
||||
|
||||
{% block modal-body-right %}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block ng_controller %}hzNamespaceResourceTypeFormController{% endblock %}
|
||||
{% block ng_controller %}hzNamespaceResourceTypeFormController as ctrl{% endblock %}
|
||||
{% block form_name %}manageResourceTypesForm{% endblock %}
|
||||
{% block form_validation %}novalidate{% endblock %}
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
<div class="fake_table fake_update_members_table">
|
||||
<div class="available_members available_update_members">
|
||||
<ul ng-repeat="resource_type in resource_types | filter:searchResource"
|
||||
<ul ng-repeat="resource_type in ctrl.resource_types | filter:searchResource"
|
||||
class="nav nav-pills btn-group {$$last ? ' last_stripe': ''$}"
|
||||
ng-class-odd="'dark_stripe'"
|
||||
ng-class-even="'light_stripe'"
|
||||
@ -76,9 +76,9 @@
|
||||
{% block modal-footer %}
|
||||
<div>
|
||||
<input class="btn btn-primary pull-right" type="submit"
|
||||
ng:click="saveResourceTypes()" value="{% trans "Save" %}"/>
|
||||
ng:click="ctrl.saveResourceTypes()" value="{% trans "Save" %}"/>
|
||||
<a class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
|
||||
<input type="hidden" name="resource_types" ng-value="resource_types"
|
||||
ng-model="resource_types">
|
||||
<input type="hidden" name="resource_types" ng-value="ctrl.resource_types"
|
||||
ng-model="ctrl.resource_types">
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -101,7 +101,7 @@ class CreateImageForm(forms.SelfHandlingForm):
|
||||
'data-source-url': _('Image Location'),
|
||||
'ng-model': 'copyFrom',
|
||||
'ng-change':
|
||||
'selectImageFormat(copyFrom)'}),
|
||||
'ctrl.selectImageFormat(copyFrom)'}),
|
||||
required=False)
|
||||
image_file = forms.FileField(label=_("Image File"),
|
||||
help_text=_("A local image to upload."),
|
||||
@ -111,7 +111,7 @@ class CreateImageForm(forms.SelfHandlingForm):
|
||||
'data-source-file': _('Image File'),
|
||||
'ng-model': 'imageFile',
|
||||
'ng-change':
|
||||
'selectImageFormat(imageFile.name)',
|
||||
'ctrl.selectImageFormat(imageFile.name)',
|
||||
'image-file-on-change': None}),
|
||||
required=False)
|
||||
kernel = forms.ChoiceField(
|
||||
@ -130,7 +130,7 @@ class CreateImageForm(forms.SelfHandlingForm):
|
||||
choices=[],
|
||||
widget=forms.Select(attrs={
|
||||
'class': 'switchable',
|
||||
'ng-model': 'diskFormat'}))
|
||||
'ng-model': 'ctrl.diskFormat'}))
|
||||
architecture = forms.CharField(max_length=255, label=_("Architecture"),
|
||||
required=False)
|
||||
minimum_disk = forms.IntegerField(
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "horizon/common/_modal_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block ng_controller %}ImageFormCtrl{% endblock %}
|
||||
{% block ng_controller %}ImageFormController as ctrl{% endblock %}
|
||||
{% block form_attrs %}enctype="multipart/form-data"{% endblock %}
|
||||
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('horizon.app.tech-debt')
|
||||
.controller('hzNamespaceResourceTypeFormController', hzNamespaceResourceTypeFormController);
|
||||
|
||||
hzNamespaceResourceTypeFormController.$inject = ['$window'];
|
||||
|
||||
function hzNamespaceResourceTypeFormController($window) {
|
||||
var ctrl = this;
|
||||
ctrl.resource_types = $window.resource_types;
|
||||
|
||||
ctrl.saveResourceTypes = function () {
|
||||
ctrl.resource_types = angular.toJson(ctrl.resource_types);
|
||||
};
|
||||
}
|
||||
|
||||
})();
|
@ -1,17 +0,0 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('horizon.app.tech-debt')
|
||||
.controller('ImageFormCtrl', ['$scope', function ($scope) {
|
||||
$scope.selectImageFormat = function (path) {
|
||||
if (!path) { return; }
|
||||
var format = path.substr(path.lastIndexOf(".") + 1)
|
||||
.toLowerCase().replace(/[^a-z0-9]+/gi, "");
|
||||
if ($('#id_disk_format').find('[value=' + format + ']').length !== 0) {
|
||||
$scope.diskFormat = format;
|
||||
} else {
|
||||
$scope.diskFormat = "";
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('horizon.app.tech-debt')
|
||||
.controller('ImageFormController', ImageFormController);
|
||||
|
||||
function ImageFormController() {
|
||||
var ctrl = this;
|
||||
|
||||
ctrl.selectImageFormat = function (path) {
|
||||
if (!path) { return; }
|
||||
var format = path.substr(path.lastIndexOf(".") + 1)
|
||||
.toLowerCase().replace(/[^a-z0-9]+/gi, "");
|
||||
/* eslint-disable angular/ng_angularelement */
|
||||
if ($('#id_disk_format').find('[value=' + format + ']').length !== 0) {
|
||||
/* eslint-enable angular/ng_angularelement */
|
||||
ctrl.diskFormat = format;
|
||||
} else {
|
||||
ctrl.diskFormat = "";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
})();
|
@ -1,12 +0,0 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('horizon.app.tech-debt')
|
||||
.controller('hzNamespaceResourceTypeFormController', function($scope, $window) {
|
||||
$scope.resource_types = $window.resource_types;
|
||||
|
||||
$scope.saveResourceTypes = function () {
|
||||
$scope.resource_types = JSON.stringify($scope.resource_types);
|
||||
};
|
||||
});
|
||||
}());
|
Loading…
Reference in New Issue
Block a user