Skip to content

Commit b4d107e

Browse files
FEATURE: Draw a properties table (#50).
* A properties table can be created from any coding memo. * Colums are inserted by adding groundings; rows are inserted as new situations. * Cells may be colored in green (when property is relevant), in red (not relevant in a selected situation) or left blank (not observed yet). * Diagrams may be created from any column header. * Properties tables can be commented. * Properties tables appears in the memos list of a diary, including the network and timeline views.
1 parent e18b4cd commit b4d107e

File tree

11 files changed

+763
-11
lines changed

11 files changed

+763
-11
lines changed

_attachments/main.css

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ html {
55

66
body {
77
height: 100%;
8-
margin: 0;
8+
margin: 0;
99
}
1010

1111
form {
1212
margin-bottom: 0px;
1313
}
1414

1515
#watermark {
16-
background-image: url(cassandre_background.png);
16+
background-image: url(cassandre_background.png);
1717
background-position: 100% 0%;
18-
background-repeat: no-repeat;
18+
background-repeat: no-repeat;
1919
}
2020

2121
#container {
@@ -221,7 +221,7 @@ button.comment {
221221
}
222222

223223
.comment {
224-
font-size: 80%;
224+
font-size: 80%;
225225
border-top: 1px solid lightgray;
226226
padding-left:5px;
227227
}
@@ -245,7 +245,7 @@ button.comment {
245245
padding-bottom: 5px;
246246
}
247247

248-
#create,#add {
248+
.create,#create,#create-table,#add {
249249
background-color:transparent;
250250
background-repeat: no-repeat;
251251
background-origin: content-box;
@@ -254,6 +254,16 @@ button.comment {
254254
width: 30px;
255255
}
256256

257+
.green {
258+
width: 100%;
259+
background-color:green;
260+
}
261+
262+
.red {
263+
width: 100%;
264+
background-color:red;
265+
}
266+
257267
.operational {
258268
background-image: url('operational.png');
259269
}
@@ -270,6 +280,10 @@ button.comment {
270280
background-image: url('field.png');
271281
}
272282

283+
.table {
284+
background-image: url('table.png');
285+
}
286+
273287
.diagram {
274288
background-image: url('diagram.png');
275289
}

_attachments/table.png

224 Bytes
Loading

l10n/i18n.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"i_sign-in": "Sign in",
1010
"i_sign-out": "Sign out",
1111
"i_sign-in_required": "You shouldn't be there",
12+
"i_situation": "Situation",
13+
"i_true": "Yes",
14+
"i_false": "No",
15+
"i_undef": "Not observed yet",
1216
"i_created-by": "Created by",
1317
"i_on-a-date": "on",
1418
"i_contributors": "Modifiable by",
@@ -104,6 +108,10 @@
104108
"i_sign-in": "S'identifier",
105109
"i_sign-out": "Se déconnecter",
106110
"i_sign-in_required": "Accès refusé",
111+
"i_situation": "Situation",
112+
"i_true": "Oui",
113+
"i_false": "Non",
114+
"i_undef": "Pas encore attesté",
107115
"i_created-by": "Créé par",
108116
"i_on-a-date": "le",
109117
"i_contributors": "Modifiable par",

lists/diary.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function(head, req) {
1919
sections: [],
2020
network: {},
2121
locale: req.headers["Accept-Language"],
22-
peer: req.peer
22+
peer: req.peer,
23+
tables: []
2324
};
2425
data.locale = data.locale.split(',');
2526
data.locale = data.locale[0].substring(0,2);
@@ -46,34 +47,48 @@ function(head, req) {
4647
switch (row.value.type) {
4748
case "field":
4849
var node_level = '2';
50+
var group = '2';
4951
var color = 'grey';
5052
break;
5153
case "coding":
5254
var node_level = '3';
55+
var group = '3';
5356
var color = 'yellow';
5457
break;
5558
case "theoretical":
5659
var node_level = '0';
60+
var group = '0';
5761
var color = 'green';
5862
break;
5963
case "diagram":
6064
data.diagrams.push(row.value.id);
6165
memos_path[row.value.id] = 'diagram';
6266
var node_level = '4';
67+
var group = '4';
68+
var color = 'purple';
69+
break;
70+
case "table":
71+
data.tables.push(row.value.id);
72+
memos_path[row.value.id] = 'table';
73+
var node_level = '4';
74+
var group = '8';
6375
var color = 'purple';
6476
break;
6577
case "operational":
6678
var node_level = '1';
79+
var group = '1';
6780
var color = 'red';
6881
break;
6982
case "graph":
7083
data.graphs.push(row.value.id);
7184
memos_path[row.value.id] = 'graph';
7285
var node_level = '5';
86+
var group = '5';
7387
var color = 'purple';
7488
break;
7589
case "storyline":
7690
var node_level = '6';
91+
var group = '6';
7792
var color = 'blue';
7893
break;
7994
}
@@ -104,7 +119,7 @@ function(head, req) {
104119
items.push({
105120
id: row.value.id,
106121
content: node_name,
107-
group: node_level,
122+
group: group,
108123
className: color,
109124
start: row.value.date.substring(0, 10)
110125
});

lists/memo.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ function(head, req) {
6464
case ('diagram'):
6565
var ground_path = '../../diagram/'+diary+'/';
6666
break;
67+
case ('table'):
68+
var ground_path = '../../table/'+diary+'/';
69+
break;
6770
case ('graph'):
6871
var ground_path = '../../graph/'+diary+'/';
6972
break;
@@ -84,7 +87,7 @@ function(head, req) {
8487
var id = row.doc._id;
8588
var href = row.doc._id;
8689
var name = row.doc.name || '...';
87-
if (type === 'diagram') href = '../../diagram/'+diary+'/'+href;
90+
if (type === 'diagram' || type === 'table') href = '../../'+type+'/'+diary+'/'+href;
8891
data.leaves.push({
8992
href: href,
9093
id: id,

lists/table.js

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
function(head, req) {
2+
// !json templates.table
3+
// !code lib/mustache.js
4+
// !code l10n/l10n.js
5+
6+
start({"headers":{"Content-Type":"text/html;charset=utf-8"}});
7+
var fullnames = [];
8+
while (row = getRow()) {
9+
switch (row.key[1]) {
10+
case ('C'):
11+
var id = row.value._id;
12+
var fullname = id;
13+
data.contributors.push(id);
14+
if (row.doc) fullname = row.doc.fullname;
15+
if (row.doc && !fullnames[id]) fullnames[id] = fullname;
16+
data.contributors_fullnames.push(fullname);
17+
break;
18+
case ('D'):
19+
if (row.doc) data.diary_name = row.doc.diary_name;
20+
break;
21+
case ('R'):
22+
var id = row.value._id;
23+
var fullname = id;
24+
data.readers.push(id);
25+
if (row.doc) fullname = row.doc.fullname;
26+
if (row.doc && !fullnames[id]) fullnames[id] = fullname;
27+
data.readers_fullnames.push(fullname);
28+
break;
29+
case ('M'):
30+
var user = row.value._id;
31+
if (row.doc && !fullnames[user]) fullnames[user] = row.doc.fullname;
32+
if (row.doc) user = row.doc.fullname;
33+
data.comments.push({
34+
user: user,
35+
date: row.value.date,
36+
text: row.value.text,
37+
id: row.value.id,
38+
rev: row.value.rev
39+
});
40+
break;
41+
case ('H'):
42+
var user = row.value._id;
43+
if (row.doc && !fullnames[user]) fullnames[user] = row.doc.fullname;
44+
if (row.doc) user = row.doc.fullname;
45+
data.creator = user;
46+
data.date = row.value.date;
47+
break;
48+
case ('G'):
49+
if (row.doc) {
50+
if (row.doc.body) {
51+
var preview = row.doc.body.substr(0, 200).replace(/\s/g, ' ');
52+
} else {
53+
if (row.doc.speeches) {
54+
var preview = row.doc.speeches[0].text.substr(0, 200) || ' ';
55+
} else {
56+
var preview = ' ';
57+
}
58+
}
59+
var ground_type = row.doc.type || 'field';
60+
switch (ground_type) {
61+
case ('diagram'):
62+
var ground_path = '';
63+
break;
64+
case ('graph'):
65+
var ground_path = '../../graph/'+diary+'/';
66+
break;
67+
default:
68+
var ground_path = '../../memo/'+diary+'/';
69+
}
70+
data.groundings.push({
71+
id: row.value._id,
72+
href: ground_path + row.value._id,
73+
type: ground_type,
74+
preview: preview,
75+
name: row.doc.name
76+
});
77+
}
78+
break;
79+
case ('L'):
80+
var type = row.doc.type || 'field';
81+
var id = row.doc._id;
82+
var href = row.doc._id;
83+
var name = row.doc.name || '...';
84+
switch (type) {
85+
case ('diagram'):
86+
break;
87+
case ('graph'):
88+
var href = '../../graph/'+diary+'/'+href;
89+
break;
90+
default:
91+
var href = '../../memo/'+diary+'/'+href;
92+
}
93+
data.leaves.push({
94+
href: href,
95+
id: id,
96+
name: name,
97+
type: type
98+
});
99+
break;
100+
default:
101+
var username = req.userCtx.name;
102+
var type = row.doc.type;
103+
var diary = row.doc.diary;
104+
var data = {
105+
i18n: localized(),
106+
_id: row.doc._id,
107+
_rev: row.doc._rev,
108+
authorized: !row.doc.readers || row.doc.readers.indexOf(username)>-1 || row.doc.contributors && row.doc.contributors.indexOf(username)>-1 || req.userCtx.roles.indexOf("_admin")>-1,
109+
body: [],
110+
cells: row.doc.cells,
111+
contributors: [],
112+
contributors_fullnames: [],
113+
comments: [],
114+
date: row.doc.date,
115+
diary: diary,
116+
groundings: [],
117+
peer: req.peer,
118+
locale: req.headers["Accept-Language"],
119+
leaves: [],
120+
logged: username,
121+
logged_fullname: username,
122+
name: row.doc.name.replace(/\s/g, ' '),
123+
readers: [],
124+
readers_fullnames: [],
125+
roles: req.userCtx.roles,
126+
type: type
127+
}
128+
data.cells = JSON.stringify(data.cells);
129+
data.locale = data.locale.split(',');
130+
data.locale = data.locale[0].substring(0,2);
131+
if (data.peer == '127.0.0.1' && req.headers['X-Forwarded-For'] ) {
132+
var ips = req.headers['X-Forwarded-For'].split(',');
133+
for (var n in ips) {
134+
if (ips[n].trim() != '127.0.0.1') data.peer = ips[n].trim();
135+
}
136+
}
137+
if (row.doc.link) {
138+
data.link = row.doc.link;
139+
if (row.doc.negative) {
140+
data.negative = row.doc.negative;
141+
}
142+
}
143+
break;
144+
}
145+
if (fullnames[username]) data.logged_fullname = fullnames[username];
146+
}
147+
return Mustache.to_html(templates.table, data);
148+
}

rewrites.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@
5252
"endkey": [":memo", {}],
5353
"include_docs": "true"
5454
}
55+
}, {
56+
"from": "table/:diary/:table",
57+
"to": "_list/table/memo",
58+
"query": {
59+
"startkey": [":table"],
60+
"endkey": [":table", {}],
61+
"include_docs": "true"
62+
}
5563
}, {
5664
"from": "diagram/:diary/:diagram",
5765
"to": "_list/diagram/memo",

shows/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function(o, req) {
66
return {
77
body: JSON.stringify({
88
service: 'Cassandre',
9-
revision: '3.17.12.04',
9+
revision: '3.18.01.31',
1010
update_seq: req.info.update_seq
1111
})
1212
}

templates/diary.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ <h1>{{diary_name}}</h1>
263263
var type = $(this).attr('class');
264264
switch(type){
265265
case "graph":
266+
case "table":
266267
case "diagram":
267268
$(this).find('a').attr('href', '../../'+type+'/{{diary}}/'+$(this).find('a').attr('href'));
268269
break;
@@ -289,13 +290,16 @@ <h1>{{diary_name}}</h1>
289290
{id: 3, content: '<img src="../../style/coding.png" />', value: 3},
290291
{id: 4, content: '<img src="../../style/diagram.png" />', value: 4},
291292
{id: 5, content: '<img src="../../style/graph.png" />', value: 5},
292-
{id: 6, content: '<img src="../../style/storyline.png" />', value: 6}
293+
{id: 6, content: '<img src="../../style/storyline.png" />', value: 6},
294+
{id: 8, content: '<img src="../../style/table.png" />', value: 8}
293295
]);
294296
timeline = new vis.Timeline(container, data, options);
295297
timeline.setGroups(groups);
296298
timeline.on('click', function (selected) {
297299
if (selected.group == 4) {
298300
self.location = '../../diagram/{{diary}}/'+selected.item;
301+
} else if (selected.group == 8) {
302+
self.location = '../../table/{{diary}}/'+selected.item;
299303
} else if (selected.group == 5) {
300304
self.location = '../../graph/{{diary}}/'+selected.item;
301305
} else if (selected.item !== null) {
@@ -311,6 +315,8 @@ <h1>{{diary_name}}</h1>
311315
diagrams = diagrams.split(',');
312316
var graphs = "{{{graphs}}}";
313317
graphs = graphs.split(',');
318+
var tables = "{{{tables}}}";
319+
tables = tables.split(',');
314320
var container = document.getElementById('network');
315321
var data = {{{network}}};
316322
var options = {
@@ -341,6 +347,8 @@ <h1>{{diary_name}}</h1>
341347
if (selected.nodes[0].length == 32) {
342348
if($.inArray(selected.nodes[0], diagrams) != -1) {
343349
self.location = '../../diagram/{{diary}}/'+selected.nodes[0];
350+
} else if($.inArray(selected.nodes[0], tables) != -1) {
351+
self.location = '../../table/{{diary}}/'+selected.nodes[0];
344352
} else if($.inArray(selected.nodes[0], graphs) != -1) {
345353
self.location = '../../graph/{{diary}}/'+selected.nodes[0];
346354
} else {

0 commit comments

Comments
 (0)