Browse Source

move api methods to api controller + add create_contact api method

damien 11 years ago
parent
commit
1fa48bd7ab

+ 14 - 2
pboard/pboard/controllers/api.py View File

@@ -42,6 +42,18 @@ class PODApiController(BaseController):
42 42
       redirect(lurl('/document/%i'%(loNewNode.parent_id)))
43 43
 
44 44
     @expose()
45
+    def create_contact(self, parent_id=None, data_label=u'', data_content=u'', **kw):
46
+
47
+      loNewNode = pld.createNode()
48
+      loNewNode.parent_id     = int(parent_id)
49
+      loNewNode.node_type     = pmd.PBNodeType.Contact
50
+      loNewNode.data_label    = data_label
51
+      loNewNode.data_content  = data_content
52
+
53
+      pm.DBSession.flush()
54
+      redirect(lurl('/document/%i'%(loNewNode.parent_id)))
55
+
56
+    @expose()
45 57
     def set_parent_node(self, node_id, new_parent_id, **kw):
46 58
       loNewNode = pld.getNode(node_id)
47 59
       if new_parent_id!='':
@@ -71,7 +83,7 @@ class PODApiController(BaseController):
71 83
       else:
72 84
         loNewNode.parent_id = parent_id
73 85
 
74
-      DBSession.flush()
86
+      pm.DBSession.flush()
75 87
       redirect(lurl('/document/%i'%(loNewNode.node_id)))
76 88
 
77 89
     @expose()
@@ -97,6 +109,6 @@ class PODApiController(BaseController):
97 109
       loNode     = pld.getNode(node_id)
98 110
       liParentId = loNode.parent_id
99 111
       if loNode.getChildNb()<=0:
100
-        DBSession.delete(loNode)
112
+        pm.DBSession.delete(loNode)
101 113
       redirect(lurl('/document/%i'%(liParentId or 0)))
102 114
 

+ 28 - 20
pboard/pboard/templates/document.mak View File

@@ -36,8 +36,8 @@
36 36
   % else:
37 37
     % if len(node_list)>0:
38 38
       % for node in node_list:
39
-        <div class="pod-toolbar-parent" style="padding-left: ${(indentation+2)*0.5}em; position: relative;">
40
-          <a href="?node=${node.node_id}" title="${node.data_label}">
39
+        <div class="pod-toolbar-parent ${'pod-status-active' if node.node_id==current_node.node_id else ''}" style="padding-left: ${(indentation+2)*0.5}em; position: relative;">
40
+          <a href="${tg.url('/document/%s'%(node.node_id))}" title="${node.data_label}">
41 41
             % if node.getStatus().status_family=='closed' or node.getStatus().status_family=='invisible':
42 42
               <strike>
43 43
             % endif
@@ -83,22 +83,6 @@ POD :: ${current_node.getTruncatedLabel(40)} [${current_node.getStatus().label}]
83 83
 
84 84
   <div class="row">
85 85
     <div class="span3">
86
-      <div class="btn-group">
87
-        <button class="btn">${_('Documents')}</button>
88
-        <button class="btn" title="${_('Show current filtering state')}"><i class="  icon-g-eye-open"></i></button>
89
-        
90
-        <a class="btn dropdown-toggle" data-toggle="dropdown" href="#" title='${_('Adjust filtering')}'><i class=" icon-g-adjust"></i></a>
91
-                <ul class="dropdown-menu">
92
-          % for node_status in node_status_list:
93
-            <li>
94
-              <a class="${node_status.css}" href="${tg.url('/edit_status?node_id=%i&node_status=%s'%(current_node.node_id, node_status.status_id))}">
95
-                <i class="${node_status.icon_id}"></i> ${node_status.label}
96
-              </a>
97
-            </li>
98
-          % endfor
99
-        </ul>
100
-      </div>
101
-      <p></p>
102 86
       <div>
103 87
         ${node_treeview(root_node_list)}
104 88
       </div>
@@ -114,7 +98,7 @@ POD :: ${current_node.getTruncatedLabel(40)} [${current_node.getStatus().label}]
114 98
         <ul class="dropdown-menu">
115 99
           % for node_status in node_status_list:
116 100
             <li>
117
-              <a class="${node_status.css}" href="${tg.url('/edit_status?node_id=%i&node_status=%s'%(current_node.node_id, node_status.status_id))}">
101
+              <a class="${node_status.css}" href="${tg.url('/api/edit_status?node_id=%i&node_status=%s'%(current_node.node_id, node_status.status_id))}">
118 102
                 <i class="${node_status.icon_id}"></i> ${node_status.label}
119 103
               </a>
120 104
             </li>
@@ -252,10 +236,34 @@ ${POD.AddButton('current-document-add-event-button', True, _(' Add event'))}
252 236
             % endif
253 237
             </div>
254 238
             <div class="tab-pane" id="contacts">
239
+            
240
+              <!-- ADD CONTACT FORM -->
241
+              ${POD.AddButton('current-document-add-contact-button', True, _(' Add contact'))}
242
+              <form style='display: none;' id='current-document-add-contact-form' action='${tg.url('/api/create_contact')}' method='post' class="well">
243
+                <input type="hidden" name='parent_id' value='${current_node.node_id}'/>
244
+                <fieldset>
245
+                  <legend>Add an event</legend>
246
+                  <label>
247
+                    <input type="text" name='data_label' placeholder="Title"/>
248
+                  </label>
249
+                  <label>
250
+                    <div>
251
+                      <textarea id="add_contact_data_content_textarea" name='data_content' spellcheck="false" wrap="off" autofocus placeholder="${_('detail...')}"></textarea>
252
+                    </div>
253
+                  </label>
254
+                  ${POD.CancelButton('current-document-add-contact-cancel-button', True)}
255
+                  ${POD.SaveButton('current-document-add-contact-save-button', True)}
256
+                </fieldset>
257
+              </form>
258
+
259
+              <!-- LIST OF CONTACT NODES -->
255 260
               % for contact in current_node.getContacts():
256 261
                 <div class="well">
257 262
                   <legend class="text-info">${contact.data_label}</legend>
258
-                  <div>${contact.data_content|n}</div>
263
+                  <div>
264
+                    <a style='float: right;' href="" title='${_('Search on google maps')}'><i class='icon-g-google-maps'></i></a>
265
+                    ${contact.data_content|n}
266
+                  </div>
259 267
                 </div>
260 268
               % endfor
261 269
             </div>

+ 30 - 2
pboard/pboard/templates/master.mak View File

@@ -105,6 +105,7 @@ tr:Hover td div.pod-toolbar {
105 105
 .pod-status-grey-light  { background-color: #DDD; }
106 106
 .pod-status-grey-middle { background-color: #BBB; }
107 107
 .pod-status-grey-dark   { background-color: #AAA; }
108
+.pod-status-active      { background-color: #FEE; }
108 109
 
109 110
 </style>
110 111
 
@@ -136,6 +137,7 @@ tr:Hover td div.pod-toolbar {
136 137
                 $('#current_node_textarea').css("min-height", "12em");
137 138
                 $('#current_node_textarea').addClass("span5");
138 139
 
140
+                /* ADD EVENT FORM */
139 141
                 $('#add_event_data_content_textarea').wysihtml5({
140 142
                   "font-styles": false, //Font styling, e.g. h1, h2, etc. Default true
141 143
                   "emphasis": true, //Italics, bold, etc. Default true
@@ -149,6 +151,19 @@ tr:Hover td div.pod-toolbar {
149 151
                 $('#add_event_data_content_textarea').css("height", "4em");
150 152
                 $('#add_event_data_content_textarea').addClass("span3");
151 153
 
154
+                /* ADD CONTACT FORM */
155
+                $('#add_contact_data_content_textarea').wysihtml5({
156
+                  "font-styles": false, //Font styling, e.g. h1, h2, etc. Default true
157
+                  "emphasis": true, //Italics, bold, etc. Default true
158
+                  "lists": false, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
159
+                  "html": true, //Button which allows you to edit the generated HTML. Default false
160
+                  "link": true, //Button to insert a link. Default true
161
+                  "image": true, //Button to insert an image. Default true,
162
+                  // "color": true //Button to change color of font  
163
+                });
164
+                $('#add_contact_data_content_textarea').css('margin-bottom', '0');
165
+                $('#add_contact_data_content_textarea').css("height", "4em");
166
+                $('#add_contact_data_content_textarea').addClass("span3");
152 167
 
153 168
 
154 169
                 /* Edit title form */
@@ -202,6 +217,19 @@ tr:Hover td div.pod-toolbar {
202 217
                   $('#current-document-add-event-form').submit();
203 218
                 });
204 219
 
220
+                /* Add contact form hide/show behavior */
221
+                $("#current-document-add-contact-button" ).click(function() {
222
+                  $("#current-document-add-contact-form" ).css("display", "block");
223
+                  $("#current-document-add-contact-button" ).css("display", "none");
224
+                });
225
+                $('#current-document-add-contact-cancel-button').on('click', function(e){
226
+                  $("#current-document-add-contact-form" ).css("display", "none");
227
+                  $("#current-document-add-contact-button" ).css("display", "block");
228
+                });
229
+                $('#current-document-add-contact-save-button').on('click', function(e){
230
+                  e.preventDefault(); // We don't want this to act as a link so cancel the link action
231
+                  $('#current-document-add-contact-form').submit();
232
+                });
205 233
 
206 234
 
207 235
 
@@ -255,9 +283,9 @@ tr:Hover td div.pod-toolbar {
255 283
         <div class="nav-collapse">
256 284
           <ul class="nav">
257 285
             <li class="active"><a href="${tg.url('/dashboard')}"><i class="icon-home icon-white"></i> Dashboard</a></li>
286
+            <li><a>Link</a></li>
258 287
             <li><a href="#">Link</a></li>
259
-            <li><a href="#">Link</a></li>
260
-            <li><a href="#">Link</a></li>
288
+
261 289
           % if request.identity:
262 290
             <li class="dropdown">
263 291
               <a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin <b class="caret"></b></a>