From 6ba34b6ad561ed00d245aeda657159ff5492a743 Mon Sep 17 00:00:00 2001 From: Nathan Zimmerman Date: Sat, 19 Sep 2015 16:02:25 -0400 Subject: [PATCH 1/3] Modularize editMediaImages directive --- oratory/www/modules/app.dir.js | 43 ----------------- www/modules/app.js | 28 +++++++++++ www/modules/editMediaImages/dir.js | 51 ++++++++++++++++++++ www/modules/editMediaImages/template.html | 9 ++++ www/modules/toolbar/template.html | 57 +++++++++++++++++++++++ 5 files changed, 145 insertions(+), 43 deletions(-) create mode 100644 www/modules/app.js create mode 100644 www/modules/editMediaImages/dir.js create mode 100644 www/modules/editMediaImages/template.html create mode 100644 www/modules/toolbar/template.html diff --git a/oratory/www/modules/app.dir.js b/oratory/www/modules/app.dir.js index 817da95..d5642eb 100644 --- a/oratory/www/modules/app.dir.js +++ b/oratory/www/modules/app.dir.js @@ -712,49 +712,6 @@ define(['angular', 'moment', 'socket', 'jquery', 'underscore'], function (angula }; } }; - }, - - - addMediaImageForm: function () { - return { - restrict: 'E', - scope: { - mediaImage: '=' - }, - templateUrl: 'html/addMediaImageForm.html', - link: function (scope, element) { - var takePicture = element.find(".take-picture"); - var showPicture = element.find(".show-picture"); - - if (takePicture && showPicture) { - // Set events - takePicture.on('change', function (event) { - - // Get a reference to the taken picture or chosen file - var files = event.target.files; - var file; - if (files && files.length > 0) { - file = files[0]; - - try { - var fileReader = new FileReader(); - fileReader.onload = function (event) { - scope.mediaImage = event.target.result; - scope.$digest(); - }; - fileReader.readAsDataURL(file); - } catch (e) { - // Display error message - scope.errorMsg = 'nothing is supported'; - } - } - - });//END take picture 'on' event - } - - - }//link - }; } }; }); diff --git a/www/modules/app.js b/www/modules/app.js new file mode 100644 index 0000000..378a030 --- /dev/null +++ b/www/modules/app.js @@ -0,0 +1,28 @@ +/*jslint browser:true */ +/*global define */ + +define([ + 'angular', + 'app.svc', + 'app.ctrl', + 'app.config', + 'app.dir', + 'toolbar/dir', + 'editOwners/dir', + 'editMediaImages/dir', + 'app.filter', + 'angular-ui-router' +], function (angular, appSvc, appCtrl, appCfg, appDir, appDirToolbar, appDirEditOwners, appDirEditMediaImages, appFilt) { + 'use strict'; + + return angular.module('app', ['ui.router']) + .factory(appSvc) + .controller(appCtrl) + .config(appCfg) + .directive(appDir) + //modules + .directive(appDirToolbar) + .directive(appDirEditOwners) + .directive(appDirEditMediaImages) + .filter(appFilt); +}); diff --git a/www/modules/editMediaImages/dir.js b/www/modules/editMediaImages/dir.js new file mode 100644 index 0000000..a518dad --- /dev/null +++ b/www/modules/editMediaImages/dir.js @@ -0,0 +1,51 @@ +/*jslint browser:true, nomen:true, vars:true */ +/*global define, FileReader */ + +define([], function () { + 'use strict'; + + + return { + editMediaImageForm: function () { + return { + restrict: 'E', + scope: { + mediaImage: '=' + }, + templateUrl: 'modules/editMediaImages/template.html', + link: function (scope, element) { + var takePicture = element.find(".take-picture"); + var showPicture = element.find(".show-picture"); + + if (takePicture && showPicture) { + // Set events + takePicture.on('change', function (event) { + + // Get a reference to the taken picture or chosen file + var files = event.target.files; + var file; + if (files && files.length > 0) { + file = files[0]; + + try { + var fileReader = new FileReader(); + fileReader.onload = function (event) { + scope.mediaImage = event.target.result; + scope.$digest(); + }; + fileReader.readAsDataURL(file); + } catch (e) { + // Display error message + scope.errorMsg = 'nothing is supported'; + } + } + + });//END take picture 'on' event + } + + + }//link + }; + } + }; +}); diff --git a/www/modules/editMediaImages/template.html b/www/modules/editMediaImages/template.html new file mode 100644 index 0000000..27b125c --- /dev/null +++ b/www/modules/editMediaImages/template.html @@ -0,0 +1,9 @@ +
+
+ +
+
+ +
+

{{errorMsg}}

+
\ No newline at end of file diff --git a/www/modules/toolbar/template.html b/www/modules/toolbar/template.html new file mode 100644 index 0000000..e62602f --- /dev/null +++ b/www/modules/toolbar/template.html @@ -0,0 +1,57 @@ +
+ + +
+
+ + + + + + + + + + +
+ + +
+ +
+ + + +
+
+ + +
+
+ add event: + + + +
+
+ add budget: + + +
+ +
+

description

+ + + +
+ + +
+
From af8c0f7d9fa1ea3f3859dddda8b6de7c179e39fc Mon Sep 17 00:00:00 2001 From: Nathan Zimmerman Date: Sat, 19 Sep 2015 16:42:03 -0400 Subject: [PATCH 2/3] Reorganize; modularize edit owners --- oratory/www/modules/app.dir.js | 89 ------------------- www/modules/app.js | 12 ++- www/modules/attachments/edit/dir.js | 22 +++++ www/modules/budget/list/dir.js | 83 +++++++++++++++++ www/modules/budget/list/template.html | 52 +++++++++++ .../edit}/dir.js | 2 +- .../edit}/template.html | 0 www/modules/owners/edit/dir.js | 23 +++++ www/modules/owners/edit/template.html | 9 ++ 9 files changed, 199 insertions(+), 93 deletions(-) create mode 100644 www/modules/attachments/edit/dir.js create mode 100644 www/modules/budget/list/dir.js create mode 100644 www/modules/budget/list/template.html rename www/modules/{editMediaImages => mediaImages/edit}/dir.js (96%) rename www/modules/{editMediaImages => mediaImages/edit}/template.html (100%) create mode 100644 www/modules/owners/edit/dir.js create mode 100644 www/modules/owners/edit/template.html diff --git a/oratory/www/modules/app.dir.js b/oratory/www/modules/app.dir.js index d5642eb..927a1a5 100644 --- a/oratory/www/modules/app.dir.js +++ b/oratory/www/modules/app.dir.js @@ -230,20 +230,6 @@ define(['angular', 'moment', 'socket', 'jquery', 'underscore'], function (angula }; }, - listAttachment: function (master) { - return { - restrict: 'E', - scope: { - attachment: '=', - editAttachment: '=' - }, - templateUrl: 'html/listAttachment.html', - link: function (scope) { - scope.colors = master.color(scope.attachment); - } - }; - }, - imageSearch: function ($http) { return { restrict: 'E', @@ -613,81 +599,6 @@ define(['angular', 'moment', 'socket', 'jquery', 'underscore'], function (angula }; }, - listBudget: function (master) { - return { - restrict: 'E', - scope: { - budget: '=', - item: '=', - editBudget: '=' - }, - templateUrl: 'html/listBudget.html', - link: function (scope) { - scope.dbInfo = master.getDbInfo; - scope.sharedData = master.sharedData; - if (!scope.budget) { - scope.budget = {}; - } - scope.budget.total = 0; - - scope.newLine = {}; - - if (scope.editBudget) { - if (!scope.budget) { - scope.budget = {}; - scope.budget.lines = []; - if (scope.item.attachments) { - //loop throught and add - _(scope.item.attachments).each(function (uid) { - var attachment = _(master.items).findWhere({uid: uid}); - if (attachment.need === 'want') { - scope.budget.lines.push({name: attachment.name, price: attachment.price}); - } - }); - } - } - } - - scope.getTotal = function () { - var total = 0; - if (!scope.budget.lines) { - scope.budget.lines = []; - } - _.forEach(scope.budget.lines, function (line) { - if ($.isNumeric(line.price)) { - total = total + Number(line.price); - } - }); - scope.budget.total = total; - }; - scope.getTotal(); - - scope.isNumber = function () { - if (!$.isNumeric(scope.newLine.price)) { - scope.newLine.price = 0; - } - }; - - scope.saveBudget = function () { - scope.item.budget = scope.budget; - master.saveItem(scope.item); - scope.$emit('closeBudget'); - }; - - scope.addLine = function () { - scope.budget.lines.push(scope.newLine); - scope.getTotal(); - scope.newLine = {}; - }; - - scope.removeLine = function (index) { - scope.budget.lines.splice(index, 1); - scope.getTotal(); - }; - } - }; - }, - listResult: function ($state, $http) { return { restrict: 'E', diff --git a/www/modules/app.js b/www/modules/app.js index 378a030..18c4cc3 100644 --- a/www/modules/app.js +++ b/www/modules/app.js @@ -8,11 +8,15 @@ define([ 'app.config', 'app.dir', 'toolbar/dir', - 'editOwners/dir', - 'editMediaImages/dir', + 'owners/edit/dir', + 'mediaImages/edit/dir', + 'budget/list/dir', + 'attachments/edit/dir', 'app.filter', 'angular-ui-router' -], function (angular, appSvc, appCtrl, appCfg, appDir, appDirToolbar, appDirEditOwners, appDirEditMediaImages, appFilt) { +], function (angular, + appSvc, appCtrl, appCfg, appDir, appDirToolbar, appDirEditOwners, appDirEditMediaImages, + budgetList, appDirEditAttachments, appFilt) { 'use strict'; return angular.module('app', ['ui.router']) @@ -24,5 +28,7 @@ define([ .directive(appDirToolbar) .directive(appDirEditOwners) .directive(appDirEditMediaImages) + .directive(budgetList) + .directive(appDirEditAttachments) .filter(appFilt); }); diff --git a/www/modules/attachments/edit/dir.js b/www/modules/attachments/edit/dir.js new file mode 100644 index 0000000..0f90281 --- /dev/null +++ b/www/modules/attachments/edit/dir.js @@ -0,0 +1,22 @@ +/*jslint browser:true, nomen:true, vars:true */ +/*global define, FileReader */ + +define([], function () { + 'use strict'; + + return { + editAttachment: function (master) { + return { + restrict: 'E', + scope: { + attachment: '=', + editAttachment: '=' + }, + templateUrl: 'modules/attachments/edit/template.html', + link: function (scope) { + scope.colors = master.color(scope.attachment); + } + }; + } + }; +}); diff --git a/www/modules/budget/list/dir.js b/www/modules/budget/list/dir.js new file mode 100644 index 0000000..ebccbd6 --- /dev/null +++ b/www/modules/budget/list/dir.js @@ -0,0 +1,83 @@ +/*jslint browser:true, nomen:true, vars:true */ +/*global define, FileReader */ + +define(['underscore', 'jquery'], function (_, $) { + 'use strict'; + + return { + listBudget: function (master) { + return { + restrict: 'E', + scope: { + budget: '=', + item: '=', + editBudget: '=' + }, + templateUrl: 'modules/budget/list/template.html', + link: function (scope) { + scope.dbInfo = master.getDbInfo; + scope.sharedData = master.sharedData; + if (!scope.budget) { + scope.budget = {}; + } + scope.budget.total = 0; + + scope.newLine = {}; + + if (scope.editBudget) { + if (!scope.budget) { + scope.budget = {}; + scope.budget.lines = []; + if (scope.item.attachments) { + //loop throught and add + _(scope.item.attachments).each(function (uid) { + var attachment = _(master.items).findWhere({uid: uid}); + if (attachment.need === 'want') { + scope.budget.lines.push({name: attachment.name, price: attachment.price}); + } + }); + } + } + } + + scope.getTotal = function () { + var total = 0; + if (!scope.budget.lines) { + scope.budget.lines = []; + } + _.forEach(scope.budget.lines, function (line) { + if ($.isNumeric(line.price)) { + total = total + Number(line.price); + } + }); + scope.budget.total = total; + }; + scope.getTotal(); + + scope.isNumber = function () { + if (!$.isNumeric(scope.newLine.price)) { + scope.newLine.price = 0; + } + }; + + scope.saveBudget = function () { + scope.item.budget = scope.budget; + master.saveItem(scope.item); + scope.$emit('closeBudget'); + }; + + scope.addLine = function () { + scope.budget.lines.push(scope.newLine); + scope.getTotal(); + scope.newLine = {}; + }; + + scope.removeLine = function (index) { + scope.budget.lines.splice(index, 1); + scope.getTotal(); + }; + } + }; + } + }; +}); diff --git a/www/modules/budget/list/template.html b/www/modules/budget/list/template.html new file mode 100644 index 0000000..d1adf6e --- /dev/null +++ b/www/modules/budget/list/template.html @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+ {{$index+1}}. + + {{line.name}} + + + {{line.price}} + + + {{line.comment}} + + + +
+ add: + + + + + + + + +
+ total: + + {{budget.total}} +
+ \ No newline at end of file diff --git a/www/modules/editMediaImages/dir.js b/www/modules/mediaImages/edit/dir.js similarity index 96% rename from www/modules/editMediaImages/dir.js rename to www/modules/mediaImages/edit/dir.js index a518dad..6dbb0a9 100644 --- a/www/modules/editMediaImages/dir.js +++ b/www/modules/mediaImages/edit/dir.js @@ -12,7 +12,7 @@ define([], function () { scope: { mediaImage: '=' }, - templateUrl: 'modules/editMediaImages/template.html', + templateUrl: 'modules/mediaImages/edit/template.html', link: function (scope, element) { var takePicture = element.find(".take-picture"); var showPicture = element.find(".show-picture"); diff --git a/www/modules/editMediaImages/template.html b/www/modules/mediaImages/edit/template.html similarity index 100% rename from www/modules/editMediaImages/template.html rename to www/modules/mediaImages/edit/template.html diff --git a/www/modules/owners/edit/dir.js b/www/modules/owners/edit/dir.js new file mode 100644 index 0000000..590e783 --- /dev/null +++ b/www/modules/owners/edit/dir.js @@ -0,0 +1,23 @@ +define([], function () { + 'use strict'; + + return { + ownerForm: function (master) { + return { + restrict: 'E', + scope: { + item: '=' + }, + templateUrl: 'modules/owners/edit/template.html', + link: function (scope) { + + scope.addOwner = function (newOwner) { + scope.item.owners.push(newOwner); + master.saveItem(scope.item); + }; + + } + }; + } + }; +}); diff --git a/www/modules/owners/edit/template.html b/www/modules/owners/edit/template.html new file mode 100644 index 0000000..8a2021d --- /dev/null +++ b/www/modules/owners/edit/template.html @@ -0,0 +1,9 @@ +
+
+
+ + + +
+
+
\ No newline at end of file From c27fd4dcf1be26a54e7d30a913c3bb79b1396ee1 Mon Sep 17 00:00:00 2001 From: Nathan Zimmerman Date: Sat, 19 Sep 2015 16:51:02 -0400 Subject: [PATCH 3/3] Modularize result list --- oratory/www/modules/app.dir.js | 27 +-------------------- www/modules/app.js | 4 +++- www/modules/result/list/dir.js | 34 +++++++++++++++++++++++++++ www/modules/result/list/template.html | 20 ++++++++++++++++ 4 files changed, 58 insertions(+), 27 deletions(-) create mode 100644 www/modules/result/list/dir.js create mode 100644 www/modules/result/list/template.html diff --git a/oratory/www/modules/app.dir.js b/oratory/www/modules/app.dir.js index 927a1a5..21302a5 100644 --- a/oratory/www/modules/app.dir.js +++ b/oratory/www/modules/app.dir.js @@ -595,34 +595,9 @@ define(['angular', 'moment', 'socket', 'jquery', 'underscore'], function (angula } - } - }; - }, - - listResult: function ($state, $http) { - return { - restrict: 'E', - scope: { - proposal: '=', - result: '=', - key: '=' - }, - templateUrl: 'html/listResult.html', - link: function (scope) { - scope.saveResult = function () { - delete scope.result.edit; - scope.proposal[scope.result.who] = scope.result; - var pushComponents = {}; - pushComponents.uid = scope.proposal.uid; - pushComponents.who = scope.result.who; - pushComponents[scope.result.who] = scope.result; - pushComponents.key = scope.key; - $http.post('/api/proposalResult', pushComponents).then(function () { - $state.go('proposal/:uid/:resultee', {uid: scope.proposal.uid, resultee: ''}); - }); - }; } }; } + }; }); diff --git a/www/modules/app.js b/www/modules/app.js index 18c4cc3..4373956 100644 --- a/www/modules/app.js +++ b/www/modules/app.js @@ -12,11 +12,12 @@ define([ 'mediaImages/edit/dir', 'budget/list/dir', 'attachments/edit/dir', + 'result/list/dir', 'app.filter', 'angular-ui-router' ], function (angular, appSvc, appCtrl, appCfg, appDir, appDirToolbar, appDirEditOwners, appDirEditMediaImages, - budgetList, appDirEditAttachments, appFilt) { + budgetList, appDirEditAttachments, appDirListResult, appFilt) { 'use strict'; return angular.module('app', ['ui.router']) @@ -30,5 +31,6 @@ define([ .directive(appDirEditMediaImages) .directive(budgetList) .directive(appDirEditAttachments) + .directive(appDirListResult) .filter(appFilt); }); diff --git a/www/modules/result/list/dir.js b/www/modules/result/list/dir.js new file mode 100644 index 0000000..09939d8 --- /dev/null +++ b/www/modules/result/list/dir.js @@ -0,0 +1,34 @@ +/*jslint browser:true, nomen:true, vars:true */ +/*global define, FileReader */ + +define([], function () { + 'use strict'; + + return { + listResult: function ($state, $http) { + return { + restrict: 'E', + scope: { + proposal: '=', + result: '=', + key: '=' + }, + templateUrl: 'modules/result/list/template.html', + link: function (scope) { + scope.saveResult = function () { + delete scope.result.edit; + scope.proposal[scope.result.who] = scope.result; + var pushComponents = {}; + pushComponents.uid = scope.proposal.uid; + pushComponents.who = scope.result.who; + pushComponents[scope.result.who] = scope.result; + pushComponents.key = scope.key; + $http.post('/api/proposalResult', pushComponents).then(function () { + $state.go('proposal/:uid/:resultee', {uid: scope.proposal.uid, resultee: ''}); + }); + }; + } + }; + } + }; +}); diff --git a/www/modules/result/list/template.html b/www/modules/result/list/template.html new file mode 100644 index 0000000..69fe3f3 --- /dev/null +++ b/www/modules/result/list/template.html @@ -0,0 +1,20 @@ +
+
{{result.who}}
+

{{result.what}}

+

no response

+ + + + +
comments
+

{{result.comment}}

+

no comments

+ + + + +
\ No newline at end of file