Updated to work better with new Additionals widget
[ajatus.git] / js / content_types / contact.js
blob0736dfd4953defc53001e26460262a8c1c97dac7
1 /*
2  * This file is part of
3  *
4  * Ajatus - Distributed CRM
5  * @requires jQuery v1.2.1
6  * 
7  * Copyright (c) 2007 Jerry Jalava <jerry.jalava@gmail.com>
8  * Copyright (c) 2007 Nemein Oy <http://nemein.com>
9  * Website: http://ajatus.info
10  * Licensed under the GPL license
11  * http://www.gnu.org/licenses/gpl.html
12  * 
13  */
15 (function($){
16     $.ajatus = $.ajatus || {};
17     $.ajatus.content_type = $.ajatus.content_type || {};
18     
19     $.ajatus.content_type.contact = function()
20     {
21         var self = this;
22         this.name = 'contact';
23         this.title = 'Contact';
24         this.in_tabs = true;
25         this.history_support = true;
26         this.update_statics = false;
27         
28         this.schema = {
29             firstname: {
30                 label: 'Firstname',
31                 widget: {
32                     name: 'text',
33                     config: {}
34                 },
35                 def_val: ''
36             },
37             lastname: {
38                 label: 'Lastname',
39                 widget: {
40                     name: 'text',
41                     config: {}
42                 },
43                 def_val: ''
44             },
45             email: {
46                 label: 'Email',
47                 widget: {
48                     name: 'text',
49                     config: {}
50                 },
51                 def_val: ''
52             },
53             phone: {
54                 label: 'Phone',
55                 widget: {
56                     name: 'text',
57                     config: {}
58                 },
59                 def_val: ''
60             },
61             organization: {
62                 label: 'Oranization',
63                 widget: {
64                     name: 'text',
65                     config: {}
66                 },
67                 def_val: ''
68             },
69             xmpp: {
70                 label: 'XMPP',
71                 widget: {
72                     name: 'text',
73                     config: {}
74                 },
75                 def_val: ''
76             },
77             skype: {
78                 label: 'Skype',
79                 widget: {
80                     name: 'text',
81                     config: {}
82                 },
83                 def_val: ''
84             },
85             description: {
86                 label: 'Description',
87                 widget: {
88                     name: 'wiki',
89                     config: {}
90                 },
91                 def_val: ''
92             },
93             tags: {
94                 label: 'Tags',
95                 widget: {
96                     name: 'tags',
97                     config: {}
98                 },
99                 def_val: []
100             }
101         };
102         this.original_schema = $.ajatus.utils.object.clone(this.schema);
104         this.title_item = [
105             'firstname', ' ', 'lastname'
106         ];
107         
108         this.views = {
109             list: function(doc) {
110                 if (   doc.value._type == 'contact'
111                     && doc.value.metadata.archived.val == false
112                     && doc.value.metadata.deleted.val == false)
113                 {
114                     map(doc.value.lastname.val, {
115                         "_type": doc.value._type,
116                         "firstname": doc.value.firstname,
117                         "lastname": doc.value.lastname,
118                         "email": doc.value.email,
119                         "phone": doc.value.phone,
120                         "tags": doc.value.tags
121                     });     
122                 }
123             }
124         };
125         
126         this.list_headers = [
127             'firstname', 'lastname', 'email', 'phone'
128         ];
129         
130         this.tab = {
131             on_click: function(e)
132             {   
133                 $.ajatus.tabs.on_click(e);                
134                 this.render();
135             }
136         };
137     };
138     
139     $.ajatus.preferences.client_defaults.content_types['contact'] = new $.ajatus.content_type.contact();
141 })(jQuery);