From d99bf5ec0e1fde798fb21d4fe173f7123426b9da Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 27 May 2014 13:18:57 -0500 Subject: [PATCH] More changes to the new design Moving modal templates into separate files Now using angularui to handle bootstrap modals --- static/css/flat-ui.css | 2 +- static/css/main.css | 3 +- static/js/app/controllers.js | 62 ++++++++++++++----- static/js/app/partials/campaigns.html | 53 +--------------- .../js/app/partials/modals/campaignModal.html | 48 ++++++++++++++ .../js/app/partials/modals/templateModal.html | 39 ++++++++++++ static/js/app/partials/templates.html | 54 +--------------- 7 files changed, 138 insertions(+), 123 deletions(-) create mode 100644 static/js/app/partials/modals/campaignModal.html create mode 100644 static/js/app/partials/modals/templateModal.html diff --git a/static/css/flat-ui.css b/static/css/flat-ui.css index e6cc6aea..067052bd 100644 --- a/static/css/flat-ui.css +++ b/static/css/flat-ui.css @@ -1175,7 +1175,7 @@ label { fieldset[disabled] .form-control { background-color: #f4f6f6; border-color: #d5dbdb; - color: #d5dbdb; + color: #555555; cursor: default; opacity: 0.7; filter: alpha(opacity=70); diff --git a/static/css/main.css b/static/css/main.css index 66028211..da6ade15 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -8,7 +8,8 @@ padding-bottom:0px; } #navbar-dropdown { - margin-top:8px; + margin-top:6px; + margin-right:15px; } .sans { font-family:'Open Sans', sans-serif !important; diff --git a/static/js/app/controllers.js b/static/js/app/controllers.js index a9f996de..310cd893 100644 --- a/static/js/app/controllers.js +++ b/static/js/app/controllers.js @@ -1,4 +1,4 @@ -app.controller('CampaignCtrl', function($scope, CampaignService, GroupService, TemplateService, ngTableParams, $http) { +app.controller('CampaignCtrl', function($scope, $modal, CampaignService, GroupService, TemplateService, ngTableParams, $http) { $scope.flashes = [] $scope.mainTableParams = new ngTableParams({ page: 1, // show first page @@ -25,12 +25,12 @@ app.controller('CampaignCtrl', function($scope, CampaignService, GroupService, T $scope.templates = templates; }) - $scope.addGroup = function() { - if ($scope.group.name != "") { + $scope.addGroup = function(group) { + if (group.name != "") { $scope.campaign.groups.push({ - name: $scope.group.name + name: group.name }); - $scope.group.name = "" + group.name = "" $scope.editGroupTableParams.reload() } }; @@ -45,6 +45,21 @@ app.controller('CampaignCtrl', function($scope, CampaignService, GroupService, T name: '', groups: [] }; + $scope.editCampaign($scope.campaign) + }; + + $scope.editCampaign = function(campaign){ + var modalInstance = $modal.open({ + templateUrl: '/js/app/partials/modals/campaignModal.html', + controller: CampaignModalCtrl, + scope: $scope + }); + + modalInstance.result.then(function(selectedItem) { + $scope.selected = selectedItem; + }, function() { + console.log('closed') + }); }; $scope.editGroupTableParams = new ngTableParams({ @@ -64,9 +79,6 @@ app.controller('CampaignCtrl', function($scope, CampaignService, GroupService, T $scope.saveCampaign = function(campaign) { $scope.flashes = [] $scope.validated = true - /*if (campaign.template.name == "") { - $scope.errorFlash("Must specify a template") - }*/ var newCampaign = new CampaignService(campaign); newCampaign.$save({}, function() { $scope.successFlash("Campaign added successfully") @@ -99,6 +111,8 @@ app.controller('CampaignCtrl', function($scope, CampaignService, GroupService, T } }); +var CampaignModalCtrl = function($scope, $modalInstance){}; + app.controller('CampaignResultsCtrl', function($scope, CampaignService, GroupService, ngTableParams, $http, $window) { id = $window.location.hash.split( '/' )[2]; $scope.flashes = [] @@ -212,7 +226,7 @@ app.controller('GroupCtrl', function($scope, GroupService, ngTableParams) { } }) -app.controller('TemplateCtrl', function($scope, TemplateService, ngTableParams) { +app.controller('TemplateCtrl', function($scope, $modal, TemplateService, ngTableParams) { $scope.mainTableParams = new ngTableParams({ page: 1, // show first page count: 10, // count per page @@ -243,6 +257,17 @@ app.controller('TemplateCtrl', function($scope, TemplateService, ngTableParams) $scope.newTemplate = false; $scope.template = template; } + var modalInstance = $modal.open({ + templateUrl: '/js/app/partials/modals/templateModal.html', + controller: TemplateModalCtrl, + scope: $scope + }); + + modalInstance.result.then(function(selectedItem) { + $scope.selected = selectedItem; + }, function() { + console.log('closed') + }); }; $scope.saveTemplate = function(template) { @@ -273,8 +298,20 @@ app.controller('TemplateCtrl', function($scope, TemplateService, ngTableParams) } }) +var TemplateModalCtrl = function($scope, $modalInstance){}; + app.controller('SettingsCtrl', function($scope, $http) { + $scope.flashes = []; $scope.user = user; + $scope.errorFlash = function(message) { + $scope.flashes = []; + $scope.flashes.push({"type" : "danger", "message" : message, "icon" : "fa-exclamation-circle"}) + } + + $scope.successFlash = function(message) { + $scope.flashes = []; + $scope.flashes.push({"type" : "success", "message" : message, "icon" : "fa-check-circle"}) + } $scope.form_data = { csrf_token : csrf_token } @@ -290,11 +327,4 @@ app.controller('SettingsCtrl', function($scope, $http) { $scope.successFlash("API Key Successfully Reset") }) } - $scope.errorFlash = function(message) { - $scope.flashes.push({"type" : "danger", "message" : message, "icon" : "fa-exclamation-circle"}) - } - - $scope.successFlash = function(message) { - $scope.flashes.push({"type" : "success", "message" : message, "icon" : "fa-check-circle"}) - } }) \ No newline at end of file diff --git a/static/js/app/partials/campaigns.html b/static/js/app/partials/campaigns.html index 4455253f..b5757cea 100644 --- a/static/js/app/partials/campaigns.html +++ b/static/js/app/partials/campaigns.html @@ -26,7 +26,7 @@
- +
 
@@ -56,55 +56,4 @@
- - diff --git a/static/js/app/partials/modals/campaignModal.html b/static/js/app/partials/modals/campaignModal.html new file mode 100644 index 00000000..1b55d394 --- /dev/null +++ b/static/js/app/partials/modals/campaignModal.html @@ -0,0 +1,48 @@ + + + + + + + diff --git a/static/js/app/partials/modals/templateModal.html b/static/js/app/partials/modals/templateModal.html new file mode 100644 index 00000000..f7e8ee7c --- /dev/null +++ b/static/js/app/partials/modals/templateModal.html @@ -0,0 +1,39 @@ + + + + diff --git a/static/js/app/partials/templates.html b/static/js/app/partials/templates.html index eee4a7d7..7628eaf3 100644 --- a/static/js/app/partials/templates.html +++ b/static/js/app/partials/templates.html @@ -21,7 +21,7 @@ Templates
- +
 
@@ -48,56 +48,4 @@
- - - \ No newline at end of file