source: extensions/rv_autocomplete/admin/variants.tpl @ 28153

Last change on this file since 28153 was 28153, checked in by rvelices, 10 years ago

autocomplete allows synonims / misspellings, etc ...

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