Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge branch '2.0' of https://github.com/SalesforceEng/Argus into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bsura committed Aug 23, 2016
2 parents 61ab7a7 + 5dae153 commit a7a9327
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions ArgusWeb/app/views/argus_custom_directives/argus-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ controlsModule.directive('agDashboardResource', ['DashboardService','$sce','$com
}
}]);

controlsModule.directive('agDashboard', ['$rootScope',function($rootScope){
controlsModule.directive('agDashboard', ['$routeParams', function($routeParams) {

return{
restrict:'E',
Expand All @@ -59,6 +59,14 @@ controlsModule.directive('agDashboard', ['$rootScope',function($rootScope){
$scope.controls = [];
this.updateControl = function(controlName, controlValue, controlType){
var controlExists = false;

// check $routeParams to override controlValue
for (var prop in $routeParams) {
if (prop == controlName) {
controlValue = $routeParams[prop];
}
};

for(var i in $scope.controls) {
if($scope.controls[i].name === controlName) {
$scope.controls[i].value = controlValue;
Expand Down Expand Up @@ -100,19 +108,27 @@ controlsModule.directive('agDashboard', ['$rootScope',function($rootScope){
}]);


controlsModule.directive('agText', ['CONFIG',function(CONFIG){

controlsModule.directive('agText', ['$routeParams', 'CONFIG', function($routeParams, CONFIG) {
return{
restrict:'EA',
scope:{
controlName:'@name',
labelName:'@label',
controlValue:'@default'
},
controller: function($scope) {
$scope.ctrlVal = $scope.controlValue;

// check $routeParams to override controlValue
for (var prop in $routeParams) {
if (prop == $scope.controlName) {
$scope.ctrlVal = $routeParams[prop];
}
};
},
require:'^agDashboard',
//templateUrl: CONFIG.templatePath + 'argus-text-control.html',
template:'<B>{{labelName}} : </B> <input type="text" ng-model="controlValue">',
link: function(scope,element,attributes,dashboardCtrl){
template:'<B>{{labelName}} : </B> <input type="text" ng-model="ctrlVal">',
link: function(scope, element, attributes, dashboardCtrl) {
dashboardCtrl.updateControl(scope.controlName, scope.controlValue, "agText");
scope.$watch('controlValue', function(newValue, oldValue){
dashboardCtrl.updateControl(scope.controlName, newValue, "agText");
Expand Down Expand Up @@ -184,7 +200,7 @@ controlsModule.directive('agDropdown', ['CONFIG', 'Tags', function(CONFIG, Tags)
}]);


controlsModule.directive('agDate', ['CONFIG',function(CONFIG){
controlsModule.directive('agDate', ['$routeParams', 'CONFIG', function($routeParams, CONFIG) {

return{
restrict:'E',
Expand All @@ -194,17 +210,26 @@ controlsModule.directive('agDate', ['CONFIG',function(CONFIG){
controlValue:'@default'
},
controller: function($scope, $filter) {
$scope.ctrlVal = $scope.controlValue;

// check $routeParams to override controlValue
for (var prop in $routeParams) {
if (prop == $scope.controlName) {
$scope.ctrlVal = $routeParams[prop];
}
};

$scope.datetimepickerConfig = {
dropdownSelector: '.my-toggle-select',
minuteStep: 1
};

$scope.onSetTime = function(newDate, oldDate) {
$scope.controlValue = $filter('date')(newDate, "short");
}
};
},
require:'^agDashboard',
template:'<B>{{labelName}} : </B><div class="dropdown" style="display: inline;"><a class="dropdown-toggle my-toggle-select" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href=""><input type="text" class="input-medium" style="color:black;" ng-model="controlValue"></a> <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> <datetimepicker ng-model="data.date" on-set-time="onSetTime(newDate, oldDate)" data-datetimepicker-config="datetimepickerConfig"></datetimepicker> </ul> </div>',
template:'<B>{{labelName}} : </B><div class="dropdown" style="display: inline;"><a class="dropdown-toggle my-toggle-select" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href=""><input type="text" class="input-medium" style="color:black;" ng-model="ctrlVal"></a> <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> <datetimepicker ng-model="data.date" on-set-time="onSetTime(newDate, oldDate)" data-datetimepicker-config="datetimepickerConfig"></datetimepicker> </ul> </div>',
link: function(scope, element, attributes, dashboardCtrl){
dashboardCtrl.updateControl(scope.controlName, scope.controlValue, "agDate");
scope.$watch('controlValue', function(newValue, oldValue){
Expand Down

0 comments on commit a7a9327

Please sign in to comment.