1 | <div class="titrePage"> |
---|
2 | <h2>RV Autocomplete {$TABSHEET_TITLE}</h2> |
---|
3 | </div> |
---|
4 | |
---|
5 | <div id="acFormContainer" style="text-align:left"> |
---|
6 | <form> |
---|
7 | <table> |
---|
8 | <tr> |
---|
9 | <td> |
---|
10 | <label for=ac_in>{'When any of the following words is entered'|@translate}:</label><br> |
---|
11 | <textarea id="ac_in" style="width:100%" rows="5"></textarea> |
---|
12 | </td> |
---|
13 | </tr> |
---|
14 | |
---|
15 | <tr> |
---|
16 | <td> |
---|
17 | <select id="ac_type"> |
---|
18 | <option value="r">{'Ignore it and'|translate}</option> |
---|
19 | <option value="a">{'Search it and'|translate}</option> |
---|
20 | </select> |
---|
21 | |
---|
22 | </td> |
---|
23 | </tr> |
---|
24 | |
---|
25 | <tr> |
---|
26 | <td> |
---|
27 | <label for=ac_out>{'Search also for any of the following'|translate}:</label><br> |
---|
28 | <textarea id="ac_out" style="width:100%" rows="3"></textarea> |
---|
29 | </td> |
---|
30 | </tr> |
---|
31 | |
---|
32 | <tr> |
---|
33 | <td> |
---|
34 | <label for=ac_comment>{'Comment'|@translate}:</label><br> |
---|
35 | <input id="ac_comment" style="width:100%"> |
---|
36 | </td> |
---|
37 | </tr> |
---|
38 | |
---|
39 | </table> |
---|
40 | </form> |
---|
41 | </div> |
---|
42 | |
---|
43 | |
---|
44 | <p><a class="openAddNew">{'Create new variants'|@translate}</a></p> |
---|
45 | <table id="csTable" class="table2"> |
---|
46 | <thead> |
---|
47 | <tr class="throw"> |
---|
48 | <th class="dtc_In">{'In'|@translate}</th> |
---|
49 | <th class="dtc_Type">{'Type'|@translate}</th> |
---|
50 | <th class="dtc_Out">{'Out'|@translate}</th> |
---|
51 | <th class="dtc_Comment">{'Comment'|@translate}</th> |
---|
52 | <th class="dtc_Actions">{'Actions'|@translate}</th> |
---|
53 | </tr> |
---|
54 | </thead> |
---|
55 | <tbody> |
---|
56 | </tbody> |
---|
57 | </table> |
---|
58 | |
---|
59 | <p><a class="openAddNew">{'Create new variants'|@translate}</a></p> |
---|
60 | |
---|
61 | {include file='include/colorbox.inc.tpl'} |
---|
62 | |
---|
63 | {combine_css path="themes/default/js/ui/theme/jquery.ui.core.css"} |
---|
64 | {combine_css path="themes/default/js/ui/theme/jquery.ui.button.css"} |
---|
65 | {combine_css path="themes/default/js/ui/theme/jquery.ui.dialog.css"} |
---|
66 | {combine_css path="themes/default/js/ui/theme/jquery.ui.theme.css"} |
---|
67 | |
---|
68 | {combine_script id="jquery.ui.dialog" load="footer" require="jquery.ui.button"} |
---|
69 | {combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'} |
---|
70 | |
---|
71 | |
---|
72 | {combine_script id="jquery.dataTables" load="footer" path="themes/default/js/plugins/jquery.dataTables.js"} |
---|
73 | |
---|
74 | {html_style}{literal} |
---|
75 | .ui-accordion-header-icon {display: none} |
---|
76 | |
---|
77 | .dtBar { |
---|
78 | text-align: right; |
---|
79 | } |
---|
80 | |
---|
81 | .dtBar DIV { |
---|
82 | display: inline; |
---|
83 | padding-right: 10px; |
---|
84 | } |
---|
85 | |
---|
86 | #csTable_filter { |
---|
87 | display: block; |
---|
88 | float: left; |
---|
89 | padding-left: 10px; |
---|
90 | } |
---|
91 | |
---|
92 | .dataTables_paginate A { |
---|
93 | padding-left: 3px; |
---|
94 | } |
---|
95 | |
---|
96 | #csTable TH { |
---|
97 | cursor: pointer; |
---|
98 | } |
---|
99 | |
---|
100 | .sorting_asc:after { content: " \2193" } |
---|
101 | .sorting_desc:after { content: " \2191" } |
---|
102 | {/literal}{/html_style} |
---|
103 | |
---|
104 | {footer_script} |
---|
105 | var SHelper = { |
---|
106 | |
---|
107 | rowFromNode: function(node) { |
---|
108 | return $(node).parents("tr"); |
---|
109 | }, |
---|
110 | |
---|
111 | del: function(node){ |
---|
112 | if (!confirm("Are you sure?")) return false; |
---|
113 | var row = SHelper.rowFromNode(node) |
---|
114 | , item=dataTable.fnGetData(row[0]); |
---|
115 | |
---|
116 | row.fadeTo(500, 0.4); |
---|
117 | (new PwgWS("")).callService( |
---|
118 | "rvac.delVariant", { key: item.key}, |
---|
119 | { |
---|
120 | method: "POST", |
---|
121 | onFailure: function(num, text) { row.stop(); row.fadeTo(0,1); alert(num + " " + text); }, |
---|
122 | onSuccess: function(result) { |
---|
123 | dataTable.fnDeleteRow( row[0] ); |
---|
124 | } |
---|
125 | } |
---|
126 | ); |
---|
127 | |
---|
128 | return false; |
---|
129 | }, |
---|
130 | |
---|
131 | add: function() { |
---|
132 | $("#ac_in,#ac_out,#ac_comment").val( "" ); |
---|
133 | $("#ac_type").val("a"); |
---|
134 | |
---|
135 | $("#acFormContainer") |
---|
136 | .dialog("option", "buttons", [{ text: "Create", click: function() { |
---|
137 | (new PwgWS("")).callService( |
---|
138 | "rvac.addVariant", { in:$("#ac_in").val(), out:$("#ac_out").val(), type:$("#ac_type").val(), comment:$("#ac_comment").val() }, |
---|
139 | { |
---|
140 | method: "POST", |
---|
141 | onFailure: function(num, text) { |
---|
142 | alert(num + " " + text); |
---|
143 | }, |
---|
144 | onSuccess: function(result) { |
---|
145 | dataTable.fnAddData(result.rule); |
---|
146 | $("#ac_in,#ac_out").val( "" ); |
---|
147 | if (result.messages.length) |
---|
148 | alert(result.messages); |
---|
149 | } |
---|
150 | } |
---|
151 | ); |
---|
152 | } |
---|
153 | }, { text: "Close", click: function(){ $(this).dialog("close") }} ]) |
---|
154 | .dialog("open"); |
---|
155 | }, |
---|
156 | |
---|
157 | edit: function(node) { |
---|
158 | var row = SHelper.rowFromNode(node) |
---|
159 | , item=dataTable.fnGetData(row[0]); |
---|
160 | |
---|
161 | $("#ac_in").val( item.in.join("\n") ); |
---|
162 | $("#ac_out").val( item.out.join("\n") ); |
---|
163 | $("#ac_type").val( item.type ); |
---|
164 | $("#ac_comment").val( item.comment ); |
---|
165 | |
---|
166 | $("#acFormContainer") |
---|
167 | .dialog("option", "buttons", [{ text: "Modify", click: function() { |
---|
168 | (new PwgWS("")).callService( |
---|
169 | "rvac.modVariant", { in:$("#ac_in").val(), out:$("#ac_out").val(), type:$("#ac_type").val(), comment:$("#ac_comment").val(), key:item.key }, |
---|
170 | { |
---|
171 | method: "POST", |
---|
172 | onFailure: function(num, text) { |
---|
173 | alert(num + " " + text); |
---|
174 | }, |
---|
175 | onSuccess: function(result) { |
---|
176 | dataTable.fnUpdate(result.rule, row[0]); |
---|
177 | if (result.messages.length) |
---|
178 | alert(result.messages); |
---|
179 | $("#acFormContainer").dialog("close"); |
---|
180 | } |
---|
181 | } |
---|
182 | ); |
---|
183 | } |
---|
184 | }, { text: "Close", click: function(){ $(this).dialog("close") }} ]) |
---|
185 | .dialog("open"); |
---|
186 | |
---|
187 | return false; |
---|
188 | } |
---|
189 | } |
---|
190 | |
---|
191 | $().ready( function() { |
---|
192 | var table = $("#csTable"); |
---|
193 | dataTable = table.dataTable( { |
---|
194 | sDom : '<"dtBar"filp>rt<"dtBar"ilp>', |
---|
195 | iDisplayLength: 100, |
---|
196 | aaData: {$variants|json_encode}, |
---|
197 | aoColumnDefs: [ { |
---|
198 | aTargets: ["dtc_In"], |
---|
199 | mData: function(item) { |
---|
200 | return item.in.join(", "); |
---|
201 | } |
---|
202 | },{ |
---|
203 | aTargets: ["dtc_Type"], |
---|
204 | bSearchable: false, |
---|
205 | mData: function(item) { |
---|
206 | return item.type; |
---|
207 | } |
---|
208 | },{ |
---|
209 | aTargets: ["dtc_Out"], |
---|
210 | mData: function(item, type) { |
---|
211 | return item.out.join(", "); |
---|
212 | } |
---|
213 | },{ |
---|
214 | aTargets: ["dtc_Comment"], |
---|
215 | mData: function(item, type) { |
---|
216 | return item.comment ? item.comment : ""; |
---|
217 | } |
---|
218 | },{ |
---|
219 | aTargets: ["dtc_Actions"], |
---|
220 | bSearchable: false, |
---|
221 | bSortable: false, |
---|
222 | mData: function(item) { |
---|
223 | return "<a href=\"\" onclick=\"return SHelper.edit(this)\" class=icon-pencil title=Edit></a>" |
---|
224 | + " <a href=\"\" onclick=\"return SHelper.del(this)\" class=icon-cancel-circled title=Delete></a>"; |
---|
225 | } |
---|
226 | } |
---|
227 | ], |
---|
228 | asStripeClasses: ["row1", "row2"], |
---|
229 | bAutoWidth: false, |
---|
230 | aaSorting: [] |
---|
231 | }); |
---|
232 | |
---|
233 | $("#acFormContainer").dialog({ |
---|
234 | autoOpen: false, |
---|
235 | modal: true, |
---|
236 | width: "auto" |
---|
237 | }); |
---|
238 | $(".openAddNew").click( SHelper.add ).button(); |
---|
239 | |
---|
240 | $("tr", table).hover( |
---|
241 | function() { |
---|
242 | $(this).addClass("ui-state-highlight"); |
---|
243 | }, |
---|
244 | function() { |
---|
245 | $(this).removeClass("ui-state-highlight"); |
---|
246 | } |
---|
247 | ); |
---|
248 | }); |
---|
249 | {/footer_script} |
---|