Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

Commit 7cbf3bf

Browse files
committed
Update steps template #32
- Refactor/rename bill-workflow to flow - Add metadata model for templates - Add view to show it. - Update bills fixtures. - Fix some old issues on flow.
1 parent 901ee76 commit 7cbf3bf

File tree

16 files changed

+220
-42
lines changed

16 files changed

+220
-42
lines changed

lib/fixtures/bills.json

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
{
2121
"number" : 1
2222
, "arriveAt" : "2014-04-01T15:00:00.001Z"
23+
, "metadata": {
24+
"members": [
25+
{
26+
"name" : "Bill Snake Charmer"
27+
, "description" : "aditional information from the author / such as afiliations etc."
28+
}
29+
]
30+
}
2331
, "name": "Budget"
2432
, "billText": {
2533
"officialTitle": ""
@@ -159,6 +167,14 @@
159167
"number" : 2
160168
, "arriveAt" : "2014-04-07T15:00:00.001Z"
161169
, "name" : "Urban planing"
170+
, "metadata": {
171+
"members": [
172+
{
173+
"name" : "Bill Snake Charmer"
174+
, "description" : "aditional information from the author / such as afiliations etc."
175+
}
176+
]
177+
}
162178
, "billText": {
163179
"officialTitle": ""
164180
, "mediaTitle": "Internet civil framework"
@@ -292,6 +308,14 @@
292308
"number" : 3
293309
, "arriveAt" : "2014-04-12T15:00:00.001Z"
294310
, "name" : "Building Specialist"
311+
, "metadata": {
312+
"members": [
313+
{
314+
"name" : "Bill Snake Charmer"
315+
, "description" : "aditional information from the author / such as afiliations etc."
316+
}
317+
]
318+
}
295319
, "billText": {
296320
"officialTitle": ""
297321
, "mediaTitle": "Internet civil framework"
@@ -430,6 +454,14 @@
430454
"number" : 4
431455
, "arriveAt" : "2014-04-28T15:00:00.001Z"
432456
, "name" : "Planification"
457+
, "metadata": {
458+
"members": [
459+
{
460+
"name" : "Bill Snake Charmer"
461+
, "description" : "aditional information from the author / such as afiliations etc."
462+
}
463+
]
464+
}
433465
, "billText": {
434466
"officialTitle": ""
435467
, "mediaTitle": "Internet civil framework"
@@ -573,6 +605,14 @@
573605
"number" : 1
574606
, "arriveAt" : "2014-04-01T15:00:00.001Z"
575607
, "name": "Planificacion"
608+
, "metadata": {
609+
"members": [
610+
{
611+
"name" : "Bill Snake Charmer"
612+
, "description" : "aditional information from the author / such as afiliations etc."
613+
}
614+
]
615+
}
576616
, "billText": {
577617
"officialTitle": ""
578618
, "mediaTitle": "Internet civil framework"
@@ -601,6 +641,14 @@
601641
"number" : 1
602642
, "arriveAt" : "2014-04-01T15:00:00.001Z"
603643
, "name": "Planeamiento urbano"
644+
, "metadata": {
645+
"members": [
646+
{
647+
"name" : "Bill Snake Charmer"
648+
, "description" : "aditional information from the author / such as afiliations etc."
649+
}
650+
]
651+
}
604652
, "billText": {
605653
"officialTitle": ""
606654
, "mediaTitle": "Internet civil framework"
@@ -642,10 +690,18 @@
642690
]
643691
, "steps": [
644692
{
645-
"number": 1,
646-
"arriveAt": "2014-04-01T15:00:00.001Z",
647-
"name": "Planeamiento urbano",
648-
"billText": {
693+
"number": 1
694+
, "arriveAt": "2014-04-01T15:00:00.001Z"
695+
, "name": "Planeamiento urbano"
696+
, "metadata": {
697+
"members": [
698+
{
699+
"name" : "Bill Snake Charmer"
700+
, "description" : "aditional information from the author / such as afiliations etc."
701+
}
702+
]
703+
}
704+
, "billText": {
649705
"officialTitle": ""
650706
, "mediaTitle": "Parque de Recreación nº1 y Planta de recuperación de residuos sólidos"
651707
, "source": "http://direitorio.fgv.br/sites/direitorio.fgv.br/files/Marco%20Civil%20-%20English%20Version%20sept2011.pdf"
@@ -713,6 +769,14 @@
713769
"number": 1,
714770
"arriveAt": "2014-04-01T15:00:00.001Z",
715771
"name": "Presupuesto",
772+
"metadata": {
773+
"members": [
774+
{
775+
"name" : "Bill Snake Charmer"
776+
, "description" : "aditional information from the author / such as afiliations etc."
777+
}
778+
]
779+
},
716780
"billText": {
717781
"officialTitle": ""
718782
, "mediaTitle": "Parque de Recreación nº1 y Planta de recuperación de residuos sólidos"

lib/bill-workflow/component.json renamed to lib/flow/component.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "bill-workflow",
3-
"description": "Workflow for bills page.",
2+
"name": "flow",
3+
"description": "Flow for bills steps.",
44
"dependencies": {
55
"visionmedia/jade": "1.3.1",
66
"component/dom": "1.0.5",
@@ -22,6 +22,9 @@
2222
"images/hexagon.png",
2323
"images/time_line.png"
2424
],
25-
"templates": [ "template.jade" ],
25+
"templates": [
26+
"template.jade",
27+
"stepTemplate.jade"
28+
],
2629
"main": "view.js"
2730
}
File renamed without changes.

lib/flow/stepTemplate.jade

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
li(on-click="{{number}}")
2+
i.fa.fa-file-text
3+
p.date {{arriveAt}}
4+
p.title {{name}}

lib/bill-workflow/styles.styl renamed to lib/flow/styles.styl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*TODO: replace with https://github.com/rschmukler/component-stylus-plugin */
22
@import "./lib/view/styles.styl"
3+
image_path = "/flow/images/"
34

45
.history
56
ol
@@ -31,7 +32,7 @@
3132

3233
ul
3334
font-size 0
34-
background url("/bill-workflow/images/time_line.png") repeat-x scroll center 68px transparent
35+
background url(image_path + "time_line.png") repeat-x scroll center 68px transparent
3536
list-style none outside none
3637
margin 0
3738
padding 0
@@ -53,7 +54,7 @@
5354

5455
&.selected
5556
margin 0
56-
background url("/bill-workflow/images/time_line.png") repeat-x scroll center 68px #ffffff
57+
background url(image_path + "time_line.png") repeat-x scroll center 68px #ffffff
5758

5859
div.block
5960
background-color #ffffff
@@ -73,7 +74,7 @@
7374
color #bbbbbb
7475

7576
i
76-
background url("/bill-workflow/images/hexagon.png") no-repeat scroll center bottom transparent
77+
background url(image_path + "hexagon.png") no-repeat scroll center bottom transparent
7778
clear both
7879
color #ffffff
7980
display block

lib/bill-workflow/template.jade renamed to lib/flow/template.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#workflow-container
1+
#flow-container
22
.historyWrapper
33
.scrollbar
44
.handle

lib/bill-workflow/view.js renamed to lib/flow/view.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
var View = require('view');
22
var template = require('./template');
3+
var stepTemplate = require('./stepTemplate');
34
var dom = require('dom');
4-
var Emitter = require('emitter');
55
var request = require('superagent');
66
var ripple = require('ripple');
77
var moment = require('moment');
88

9-
module.exports = WorkflowView;
10-
11-
function WorkflowView() {
12-
if (!this instanceof WorkflowView) {
13-
return new WorkflowView();
9+
function FlowView() {
10+
if (!this instanceof FlowView) {
11+
return new FlowView();
1412
}
1513

1614
View.call(this, template);
1715
}
1816

19-
View(WorkflowView);
17+
module.exports = FlowView;
18+
19+
View(FlowView);
2020

2121
/**
2222
* Click over some step to set active.
2323
* @param {Object} el Dom node.
2424
* @param {Object} step Step data.
2525
* @param {Object} prevStep previous step
2626
*/
27-
WorkflowView.prototype.onClickStep = function (el, step, prevStep) {
27+
FlowView.prototype.onClickStep = function (el, step, prevStep) {
2828
var currentStep = step;
2929
this.el.find('li').removeClass('selected');
3030
dom(el).addClass('selected');
@@ -36,7 +36,7 @@ WorkflowView.prototype.onClickStep = function (el, step, prevStep) {
3636
* .
3737
* @param {String} billId Bill id to request steps.
3838
*/
39-
WorkflowView.prototype.loadSteps = function (billId) {
39+
FlowView.prototype.loadSteps = function (billId) {
4040
var billUrl = '/api/bill/' + billId + '/step/all';
4141
var self = this;
4242

@@ -61,21 +61,17 @@ WorkflowView.prototype.loadSteps = function (billId) {
6161
* @param {Object} step current step
6262
* @param {Object} prevStep Previous step
6363
*/
64-
WorkflowView.prototype.createStepView = function (step, prevStep) {
65-
var Template = ripple('<li on-click="{{number}}">' +
66-
'<i class="fa fa-file-text"></i>' +
67-
'<p class="date">{{arriveAt}}</p>' +
68-
'<p class="title">{{name}}</p>' +
69-
'</li>');
70-
64+
FlowView.prototype.createStepView = function (step, prevStep) {
65+
var Template = ripple(stepTemplate());
7166
var self = this;
67+
7268
Template.directive('on-click', function (number, el, view) {
7369
el.addEventListener('click', function () {
7470
self.onClickStep(el, step, prevStep);
7571
});
7672
});
7773

7874
step.arriveAt = moment(step.arriveAt).format("DD-MM-YYYY");
79-
var stepTemplate = new Template(step);
80-
stepTemplate.appendTo('.frame ul');
75+
var stepView = new Template(step);
76+
stepView.appendTo('.frame ul');
8177
};

lib/homepage/component.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
},
99
"local": [
1010
"view",
11-
"bill-workflow",
11+
"flow",
1212
"bill-view",
1313
"sidebar",
14-
"bill-diff"
14+
"bill-diff",
15+
"step-info"
1516
],
1617
"scripts": [
1718
"homepage.js",

lib/homepage/view.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
/**
22
* Module dependencies.
33
*/
4-
54
var template = require('./template');
65
var View = require('view');
7-
var WorkflowView = require('bill-workflow');
6+
var FlowView = require('flow');
87
var DiffView = require('bill-diff');
98
var BillView = require('bill-view');
109
var SidebarView = require('sidebar');
11-
12-
/**
13-
* Expose HomepageView
14-
*/
15-
16-
module.exports = HomepageView;
10+
var StepInfoView = require('step-info');
1711

1812
/**
1913
* Creates `HomepageView`
@@ -38,9 +32,13 @@ HomepageView.prototype.appendElementsToMainView = function () {
3832
var billView = new BillView();
3933
mainView.append(billView.el);
4034

41-
var workflowView = new WorkflowView();
35+
var workflowView = new FlowView();
4236
mainView.append(workflowView.el);
4337

38+
var stepInfo = new StepInfoView();
39+
mainView.append(stepInfo.el);
40+
workflowView.on('step:change', stepInfo.loadData.bind(stepInfo));
41+
4442
var diffView = new DiffView();
4543
mainView.append(diffView.el);
4644
workflowView.on('step:change', diffView.changeBillContent.bind(diffView));
@@ -54,3 +52,7 @@ HomepageView.prototype.appendElementsToMainView = function () {
5452
sidebar.on('sidebar:click-at', workflowView.loadSteps.bind(workflowView));
5553
};
5654

55+
/**
56+
* Expose HomepageView
57+
*/
58+
module.exports = HomepageView;

0 commit comments

Comments
 (0)