Repository navigation
Expand file tree
/
Copy pathType.js
More file actions
87 lines (78 loc) · 2.07 KB
/
Copy pathType.js
File metadata and controls
87 lines (78 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* Type
*
* @module :: Model
* @description :: This model represent task types on taskboard. Basically this types are "static":
* - 1 = normal
* - 2 = bug
* - 3 = test
* @todo :: 1) Make types to be project specified.
* 2) Remove class and classText attributes and replace those by color definitions.
* @docs :: http://sailsjs.org/#!documentation/models
*/
"use strict";
var _ = require("lodash");
module.exports = _.merge(_.cloneDeep(require("../services/baseModel")), {
attributes: {
// Title of type
title: {
type: "string",
required: true
},
// Order of type
order: {
type: "integer",
required: true
},
// Type color in charts
chartColor: {
type: "string",
required: true
},
// CSS class of type
class: {
type: "string",
required: true
},
// CSS class for type text
classText: {
type: "string",
required: true
}
},
// Life cycle callbacks
/**
* After create callback.
*
* @param {sails.model.type} values
* @param {Function} next
*/
afterCreate: function(values, next) {
HistoryService.write("Type", values);
next();
},
/**
* After update callback.
*
* @param {sails.model.type} values
* @param {Function} next
*/
afterUpdate: function(values, next) {
HistoryService.write("Type", values);
next();
},
/**
* Before destroy callback.
*
* @param {{}} terms
* @param {Function} next
*/
beforeDestroy: function(terms, next) {
DataService.getType(terms, function(error, type) {
if (!error) {
HistoryService.remove("Type", type.id);
}
next(error);
});
}
});