diff --git a/www/assets/dashboard.css.spt b/www/assets/dashboard.css.spt new file mode 100644 index 0000000000..c9af77662a --- /dev/null +++ b/www/assets/dashboard.css.spt @@ -0,0 +1,7 @@ +[---] +[---] text/css via scss +#dashboard { + section { + display: none; + } +} diff --git a/www/assets/dashboard.js b/www/assets/dashboard.js index d009f8184e..96f500f912 100644 --- a/www/assets/dashboard.js +++ b/www/assets/dashboard.js @@ -1,5 +1,21 @@ Dashboard = {models: {}, views: {}, collections: {}}; +Dashboard.Router = Backbone.Router.extend({ + routes: {'ledger': 'ledger', 'accounts': 'accounts'}, + ledger: function() { + $('section').hide(); + $('#general-ledger').show(); + }, + accounts: function() { + $('section').hide(); + $('#chart-of-accounts').show(); + } +}); + + +// Models +// ====== + Dashboard.models.Account = Backbone.Model.extend({ defaults: { number: null, @@ -8,21 +24,54 @@ Dashboard.models.Account = Backbone.Model.extend({ } }); + +// Collections +// =========== + Dashboard.collections.Accounts = Backbone.Collection.extend({ - url: '/dashboard/accounts/', + url: '/v2/accounts/', model: Dashboard.models.Account, parse: function(data) { return data.accounts; } }); + +// Views +// ===== + +Dashboard.views.Main = Backbone.View.extend({ + el: 'body', + initialize: function() { + new Dashboard.views.GeneralLedger; + new Dashboard.views.ChartOfAccounts; + + this.router = new Dashboard.Router; + Backbone.history.start({pushState: true, root: "/dashboard/"}); + }, + events: { + 'click #navigation a': 'loadSection' + }, + loadSection: function(e) { + this.router.navigate($(e.currentTarget).attr('href'), {trigger: true}); + e.preventDefault(); + }, +}); + +Dashboard.views.GeneralLedger = Backbone.View.extend({ + el: '#general-ledger', + initialize: function() { + this.$tbody= this.$('tbody'); + }, +}); + Dashboard.views.ChartOfAccounts = Backbone.View.extend({ el: '#chart-of-accounts', initialize: function() { this.$tbody= this.$('tbody'); this.data = new Dashboard.collections.Accounts(); - this.data.fetch({reset:true}); this.listenTo(this.data, 'reset', this.addAll); + this.data.fetch({reset:true}); }, addOne: function (account) { var view = new Dashboard.views.AccountRow({model: account}); @@ -46,6 +95,10 @@ Dashboard.views.AccountRow = Backbone.View.extend({ } }); + +// Entrypoint +// ========== + Dashboard.init = function() { - new Dashboard.views.ChartOfAccounts(); + new Dashboard.views.Main(); }; diff --git a/www/dashboard/%index.spt b/www/dashboard/%index.spt new file mode 100644 index 0000000000..d88759e774 --- /dev/null +++ b/www/dashboard/%index.spt @@ -0,0 +1,57 @@ +from aspen import Response +[---] +if user.ANON: + raise Response(401) +if not user.ADMIN: + raise Response(403) +[---] text/html + + + Dashboard + + + + + + + + +

Dashboard

+ + +
+

General Ledger

+ + + + + + + +
AccountDebitsCredits
+
+ +
+

Chart of Accounts

+ + + + + + + +
NumberNameType
+
+ + + + diff --git a/www/dashboard/accounts/index.spt b/www/dashboard/accounts/index.spt deleted file mode 100644 index 0c9c6fdad4..0000000000 --- a/www/dashboard/accounts/index.spt +++ /dev/null @@ -1,43 +0,0 @@ -from aspen import Response -[---] -if user.ANON: - raise Response(401) -if not user.ADMIN: - raise Response(403) - -out = {"accounts": [ {"number": "100", "name": "accounts receivable", "kind": "asset"} - , {"number": "200", "name": "accounts payable", "kind": "liability"} - ]} -[---] application/json via json_dump -out -[---] text/html - - - - Chart of Accounts - - - - - - - -

Chart of Accounts

- - - - - - - -
NumberNameType
- - - - diff --git a/www/dashboard/index.spt b/www/dashboard/index.spt deleted file mode 100644 index a6629c5365..0000000000 --- a/www/dashboard/index.spt +++ /dev/null @@ -1,13 +0,0 @@ -from aspen import Response -[---] -if user.ANON: - raise Response(401) -if not user.ADMIN: - raise Response(403) -[---] text/html -

Dashboard

- diff --git a/www/dashboard/ledger.spt b/www/dashboard/ledger.spt deleted file mode 100644 index 5949017cd2..0000000000 --- a/www/dashboard/ledger.spt +++ /dev/null @@ -1,21 +0,0 @@ -from aspen import Response -[---] -if user.ANON: - raise Response(401) -if not user.ADMIN: - raise Response(403) -[---] text/html - - - - - - -
- - -
-

Hello {{yourName}}!

-
- - diff --git a/www/v2/accounts/index.spt b/www/v2/accounts/index.spt new file mode 100644 index 0000000000..c7eb8d2f1e --- /dev/null +++ b/www/v2/accounts/index.spt @@ -0,0 +1,12 @@ +from aspen import Response +[---] +if user.ANON: + raise Response(401) +if not user.ADMIN: + raise Response(403) + +out = {"accounts": [ {"number": "100", "name": "accounts receivable", "type": "asset"} + , {"number": "200", "name": "accounts payable", "type": "liability"} + ]} +[---] application/json via json_dump +out