~jjacobs/frack/1069658-empty-ticket-modification-element

« back to all changes in this revision

Viewing changes to frack/media/fracklets/ChangelogItem.js

  • Committer: Allen Short
  • Date: 2012-04-16 06:13:03 UTC
  • Revision ID: washort@divmod.com-20120416061303-ahyn3ljkjymr7bg1
remove mustache, use dojo templated widgets

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
define(["dojo/_base/declare","dijit/_WidgetBase", "dijit/_TemplatedMixin", "dojo/dom-construct", "dojo/query",  "dojo/text!./ChangelogItem.html", "dojo/NodeList-manipulate"],
 
2
function(declare, WidgetBase, TemplatedMixin, domC, q, template) {
 
3
 
 
4
  return declare([WidgetBase, TemplatedMixin], {
 
5
                   templateString: template,
 
6
                   baseClass: "printableform",
 
7
                   comment: null,
 
8
                   buildRendering: function() {
 
9
                     var widget = this;
 
10
                     widget.inherited(arguments);
 
11
                     widget.changes.forEach(
 
12
                       function (change) {
 
13
                         function insertChangeline(bits) {
 
14
                           var line = q(domC.create("li"))
 
15
                             .append(q(domC.create("strong", {"class": "column"}))
 
16
                                       .text(change.field));
 
17
                           bits.forEach(function (b) {line.append(b);});
 
18
                           q(widget.changelineList).append(line);
 
19
                         }
 
20
                         function emstring(str) {
 
21
                           return q(domC.create("em")).text(str);
 
22
                         }
 
23
                         if (change.field == 'description') {
 
24
                           insertChangeline([" modified"]);
 
25
                         } else if (!change.oldvalue) {
 
26
                           insertChangeline(
 
27
                             [" set to ",emstring(change.newvalue)]);
 
28
 
 
29
                         } else if (!change.newvalue) {
 
30
                           insertChangeline([" removed"]);
 
31
                         } else {
 
32
                           insertChangeline(
 
33
                             [" changed from ",
 
34
                              emstring(change.oldvalue),
 
35
                              " to ",
 
36
                              emstring(change.newvalue)]);
 
37
                         }
 
38
                       });
 
39
                   }});
 
40
});