Skip to content

Commit

Permalink
FEATURE: Draw a properties table (#50).
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
christophe-lejeune committed Jan 31, 2018
1 parent e18b4cd commit b4d107e
Show file tree
Hide file tree
Showing 11 changed files with 763 additions and 11 deletions.
24 changes: 19 additions & 5 deletions _attachments/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ html {

body {
height: 100%;
margin: 0;
margin: 0;
}

form {
margin-bottom: 0px;
}

#watermark {
background-image: url(cassandre_background.png);
background-image: url(cassandre_background.png);
background-position: 100% 0%;
background-repeat: no-repeat;
background-repeat: no-repeat;
}

#container {
Expand Down Expand Up @@ -221,7 +221,7 @@ button.comment {
}

.comment {
font-size: 80%;
font-size: 80%;
border-top: 1px solid lightgray;
padding-left:5px;
}
Expand All @@ -245,7 +245,7 @@ button.comment {
padding-bottom: 5px;
}

#create,#add {
.create,#create,#create-table,#add {
background-color:transparent;
background-repeat: no-repeat;
background-origin: content-box;
Expand All @@ -254,6 +254,16 @@ button.comment {
width: 30px;
}

.green {
width: 100%;
background-color:green;
}

.red {
width: 100%;
background-color:red;
}

.operational {
background-image: url('operational.png');
}
Expand All @@ -270,6 +280,10 @@ button.comment {
background-image: url('field.png');
}

.table {
background-image: url('table.png');
}

.diagram {
background-image: url('diagram.png');
}
Expand Down
Binary file added _attachments/table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions l10n/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"i_sign-in": "Sign in",
"i_sign-out": "Sign out",
"i_sign-in_required": "You shouldn't be there",
"i_situation": "Situation",
"i_true": "Yes",
"i_false": "No",
"i_undef": "Not observed yet",
"i_created-by": "Created by",
"i_on-a-date": "on",
"i_contributors": "Modifiable by",
Expand Down Expand Up @@ -104,6 +108,10 @@
"i_sign-in": "S'identifier",
"i_sign-out": "Se déconnecter",
"i_sign-in_required": "Accès refusé",
"i_situation": "Situation",
"i_true": "Oui",
"i_false": "Non",
"i_undef": "Pas encore attesté",
"i_created-by": "Créé par",
"i_on-a-date": "le",
"i_contributors": "Modifiable par",
Expand Down
19 changes: 17 additions & 2 deletions lists/diary.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function(head, req) {
sections: [],
network: {},
locale: req.headers["Accept-Language"],
peer: req.peer
peer: req.peer,
tables: []
};
data.locale = data.locale.split(',');
data.locale = data.locale[0].substring(0,2);
Expand All @@ -46,34 +47,48 @@ function(head, req) {
switch (row.value.type) {
case "field":
var node_level = '2';
var group = '2';
var color = 'grey';
break;
case "coding":
var node_level = '3';
var group = '3';
var color = 'yellow';
break;
case "theoretical":
var node_level = '0';
var group = '0';
var color = 'green';
break;
case "diagram":
data.diagrams.push(row.value.id);
memos_path[row.value.id] = 'diagram';
var node_level = '4';
var group = '4';
var color = 'purple';
break;
case "table":
data.tables.push(row.value.id);
memos_path[row.value.id] = 'table';
var node_level = '4';
var group = '8';
var color = 'purple';
break;
case "operational":
var node_level = '1';
var group = '1';
var color = 'red';
break;
case "graph":
data.graphs.push(row.value.id);
memos_path[row.value.id] = 'graph';
var node_level = '5';
var group = '5';
var color = 'purple';
break;
case "storyline":
var node_level = '6';
var group = '6';
var color = 'blue';
break;
}
Expand Down Expand Up @@ -104,7 +119,7 @@ function(head, req) {
items.push({
id: row.value.id,
content: node_name,
group: node_level,
group: group,
className: color,
start: row.value.date.substring(0, 10)
});
Expand Down
5 changes: 4 additions & 1 deletion lists/memo.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ function(head, req) {
case ('diagram'):
var ground_path = '../../diagram/'+diary+'/';
break;
case ('table'):
var ground_path = '../../table/'+diary+'/';
break;
case ('graph'):
var ground_path = '../../graph/'+diary+'/';
break;
Expand All @@ -84,7 +87,7 @@ function(head, req) {
var id = row.doc._id;
var href = row.doc._id;
var name = row.doc.name || '...';
if (type === 'diagram') href = '../../diagram/'+diary+'/'+href;
if (type === 'diagram' || type === 'table') href = '../../'+type+'/'+diary+'/'+href;
data.leaves.push({
href: href,
id: id,
Expand Down
148 changes: 148 additions & 0 deletions lists/table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
function(head, req) {
// !json templates.table
// !code lib/mustache.js
// !code l10n/l10n.js

start({"headers":{"Content-Type":"text/html;charset=utf-8"}});
var fullnames = [];
while (row = getRow()) {
switch (row.key[1]) {
case ('C'):
var id = row.value._id;
var fullname = id;
data.contributors.push(id);
if (row.doc) fullname = row.doc.fullname;
if (row.doc && !fullnames[id]) fullnames[id] = fullname;
data.contributors_fullnames.push(fullname);
break;
case ('D'):
if (row.doc) data.diary_name = row.doc.diary_name;
break;
case ('R'):
var id = row.value._id;
var fullname = id;
data.readers.push(id);
if (row.doc) fullname = row.doc.fullname;
if (row.doc && !fullnames[id]) fullnames[id] = fullname;
data.readers_fullnames.push(fullname);
break;
case ('M'):
var user = row.value._id;
if (row.doc && !fullnames[user]) fullnames[user] = row.doc.fullname;
if (row.doc) user = row.doc.fullname;
data.comments.push({
user: user,
date: row.value.date,
text: row.value.text,
id: row.value.id,
rev: row.value.rev
});
break;
case ('H'):
var user = row.value._id;
if (row.doc && !fullnames[user]) fullnames[user] = row.doc.fullname;
if (row.doc) user = row.doc.fullname;
data.creator = user;
data.date = row.value.date;
break;
case ('G'):
if (row.doc) {
if (row.doc.body) {
var preview = row.doc.body.substr(0, 200).replace(/\s/g, ' ');
} else {
if (row.doc.speeches) {
var preview = row.doc.speeches[0].text.substr(0, 200) || ' ';
} else {
var preview = ' ';
}
}
var ground_type = row.doc.type || 'field';
switch (ground_type) {
case ('diagram'):
var ground_path = '';
break;
case ('graph'):
var ground_path = '../../graph/'+diary+'/';
break;
default:
var ground_path = '../../memo/'+diary+'/';
}
data.groundings.push({
id: row.value._id,
href: ground_path + row.value._id,
type: ground_type,
preview: preview,
name: row.doc.name
});
}
break;
case ('L'):
var type = row.doc.type || 'field';
var id = row.doc._id;
var href = row.doc._id;
var name = row.doc.name || '...';
switch (type) {
case ('diagram'):
break;
case ('graph'):
var href = '../../graph/'+diary+'/'+href;
break;
default:
var href = '../../memo/'+diary+'/'+href;
}
data.leaves.push({
href: href,
id: id,
name: name,
type: type
});
break;
default:
var username = req.userCtx.name;
var type = row.doc.type;
var diary = row.doc.diary;
var data = {
i18n: localized(),
_id: row.doc._id,
_rev: row.doc._rev,
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,
body: [],
cells: row.doc.cells,
contributors: [],
contributors_fullnames: [],
comments: [],
date: row.doc.date,
diary: diary,
groundings: [],
peer: req.peer,
locale: req.headers["Accept-Language"],
leaves: [],
logged: username,
logged_fullname: username,
name: row.doc.name.replace(/\s/g, ' '),
readers: [],
readers_fullnames: [],
roles: req.userCtx.roles,
type: type
}
data.cells = JSON.stringify(data.cells);
data.locale = data.locale.split(',');
data.locale = data.locale[0].substring(0,2);
if (data.peer == '127.0.0.1' && req.headers['X-Forwarded-For'] ) {
var ips = req.headers['X-Forwarded-For'].split(',');
for (var n in ips) {
if (ips[n].trim() != '127.0.0.1') data.peer = ips[n].trim();
}
}
if (row.doc.link) {
data.link = row.doc.link;
if (row.doc.negative) {
data.negative = row.doc.negative;
}
}
break;
}
if (fullnames[username]) data.logged_fullname = fullnames[username];
}
return Mustache.to_html(templates.table, data);
}
8 changes: 8 additions & 0 deletions rewrites.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
"endkey": [":memo", {}],
"include_docs": "true"
}
}, {
"from": "table/:diary/:table",
"to": "_list/table/memo",
"query": {
"startkey": [":table"],
"endkey": [":table", {}],
"include_docs": "true"
}
}, {
"from": "diagram/:diary/:diagram",
"to": "_list/diagram/memo",
Expand Down
2 changes: 1 addition & 1 deletion shows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function(o, req) {
return {
body: JSON.stringify({
service: 'Cassandre',
revision: '3.17.12.04',
revision: '3.18.01.31',
update_seq: req.info.update_seq
})
}
Expand Down
10 changes: 9 additions & 1 deletion templates/diary.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ <h1>{{diary_name}}</h1>
var type = $(this).attr('class');
switch(type){
case "graph":
case "table":
case "diagram":
$(this).find('a').attr('href', '../../'+type+'/{{diary}}/'+$(this).find('a').attr('href'));
break;
Expand All @@ -289,13 +290,16 @@ <h1>{{diary_name}}</h1>
{id: 3, content: '<img src="../../style/coding.png" />', value: 3},
{id: 4, content: '<img src="../../style/diagram.png" />', value: 4},
{id: 5, content: '<img src="../../style/graph.png" />', value: 5},
{id: 6, content: '<img src="../../style/storyline.png" />', value: 6}
{id: 6, content: '<img src="../../style/storyline.png" />', value: 6},
{id: 8, content: '<img src="../../style/table.png" />', value: 8}
]);
timeline = new vis.Timeline(container, data, options);
timeline.setGroups(groups);
timeline.on('click', function (selected) {
if (selected.group == 4) {
self.location = '../../diagram/{{diary}}/'+selected.item;
} else if (selected.group == 8) {
self.location = '../../table/{{diary}}/'+selected.item;
} else if (selected.group == 5) {
self.location = '../../graph/{{diary}}/'+selected.item;
} else if (selected.item !== null) {
Expand All @@ -311,6 +315,8 @@ <h1>{{diary_name}}</h1>
diagrams = diagrams.split(',');
var graphs = "{{{graphs}}}";
graphs = graphs.split(',');
var tables = "{{{tables}}}";
tables = tables.split(',');
var container = document.getElementById('network');
var data = {{{network}}};
var options = {
Expand Down Expand Up @@ -341,6 +347,8 @@ <h1>{{diary_name}}</h1>
if (selected.nodes[0].length == 32) {
if($.inArray(selected.nodes[0], diagrams) != -1) {
self.location = '../../diagram/{{diary}}/'+selected.nodes[0];
} else if($.inArray(selected.nodes[0], tables) != -1) {
self.location = '../../table/{{diary}}/'+selected.nodes[0];
} else if($.inArray(selected.nodes[0], graphs) != -1) {
self.location = '../../graph/{{diary}}/'+selected.nodes[0];
} else {
Expand Down
Loading

0 comments on commit b4d107e

Please sign in to comment.