Intial
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(Array.prototype, 'count', {
|
||||
get: function () { return this.length; }
|
||||
});
|
||||
|
||||
if (Array.prototype.addRange) return;
|
||||
|
||||
Array.prototype.addRange = function (target) {
|
||||
this.push.apply(this, target);
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,51 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
window.app.directive('formGroupValidation', formGroupValidation);
|
||||
|
||||
function formGroupValidation() {
|
||||
return {
|
||||
require: '^form',
|
||||
replace: true,
|
||||
transclude: true,
|
||||
template:
|
||||
'<div class="has-feedback" ng-class="vm.getValidationClass()">' +
|
||||
'<ng-transclude></ng-transclude>' +
|
||||
'<input-validation-icons field="vm.field"></input-validation-icons>' +
|
||||
'</div>',
|
||||
scope: {
|
||||
field: '@formGroupValidation'
|
||||
},
|
||||
controller: controller,
|
||||
controllerAs: 'vm',
|
||||
link: function (scope, element, attrs, formCtrl) {
|
||||
scope.form = formCtrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope'];
|
||||
function controller($scope) {
|
||||
var vm = this;
|
||||
|
||||
vm.field = $scope.field;
|
||||
vm.getValidationClass = getValidationClass;
|
||||
|
||||
function getValidationClass() {
|
||||
if (!canBeValidated()) return '';
|
||||
|
||||
if (isValid()) return 'has-success';
|
||||
|
||||
return 'has-error';
|
||||
}
|
||||
|
||||
function canBeValidated() {
|
||||
return ($scope.form[vm.field].$touched || $scope.form.$submitted);
|
||||
}
|
||||
|
||||
function isValid() {
|
||||
return $scope.form[vm.field].$valid;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,41 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
window.app.directive('inputValidationIcons', inputValidationIcons);
|
||||
|
||||
function inputValidationIcons() {
|
||||
return {
|
||||
require: '^form',
|
||||
scope: {
|
||||
field: '='
|
||||
},
|
||||
template:
|
||||
'<span ng-show="vm.canBeValidated() && vm.isValid()" ' +
|
||||
'class="fa fa-2x fa-check-square form-control-feedback"></span>' +
|
||||
'<span ng-show="vm.canBeValidated() && !vm.isValid()" ' +
|
||||
'class="fa fa-2x fa-exclamation-triangle form-control-feedback"></span>',
|
||||
controller: controller,
|
||||
controllerAs: 'vm',
|
||||
link: function (scope, element, attrs, formCtrl) {
|
||||
scope.form = formCtrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope'];
|
||||
function controller($scope) {
|
||||
var vm = this;
|
||||
|
||||
vm.field = $scope.field;
|
||||
vm.canBeValidated = canBeValidated;
|
||||
vm.isValid = isValid;
|
||||
|
||||
function canBeValidated() {
|
||||
return ($scope.form[vm.field].$touched || $scope.form.$submitted);
|
||||
}
|
||||
|
||||
function isValid() {
|
||||
return $scope.form[vm.field].$valid;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,46 @@
|
||||
(function () {
|
||||
|
||||
window.app.directive('mvcGrid', mvcGrid);
|
||||
function mvcGrid() {
|
||||
return {
|
||||
scope: {
|
||||
gridDataUrl: '@',
|
||||
title: '@',
|
||||
columns: '@?'
|
||||
},
|
||||
template:
|
||||
'<div>' +
|
||||
'<h4><i class="fa fa-pie-chart fa-fw"></i> {{vm.title}}</h4>' +
|
||||
'<div>' +
|
||||
'<p ng-if="vm.loading">Loading...</p>' +
|
||||
'<div ng-if="!vm.loading" ui-grid="vm.gridOptions"></div>' +
|
||||
'</div>' +
|
||||
'</div>',
|
||||
controllerAs: 'vm',
|
||||
controller: controller
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', '$http'];
|
||||
function controller($scope, $http) {
|
||||
var vm = this;
|
||||
|
||||
vm.gridOptions = {
|
||||
enableHorizontalScrollbar: 0
|
||||
}
|
||||
|
||||
vm.loading = true;
|
||||
|
||||
vm.title = $scope.title;
|
||||
|
||||
if ($scope.columns)
|
||||
vm.gridOptions.columnDefs = angular.fromJson($scope.columns);
|
||||
|
||||
$http.post($scope.gridDataUrl)
|
||||
.success(function (data) {
|
||||
vm.gridOptions.data = data;
|
||||
vm.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,11 @@
|
||||
(function() {
|
||||
window.app.filter('parseDate', parseDate);
|
||||
|
||||
function parseDate() {
|
||||
return function(input) {
|
||||
if (typeof input != 'string' || input.indexOf('/Date') === -1) return input;
|
||||
|
||||
return new Date(parseInt(input.substr(6)));
|
||||
}
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user