populate-me 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/populate_me/admin/__assets__/css/main.css +7 -3
- data/lib/populate_me/admin/__assets__/js/columnav.js +12 -8
- data/lib/populate_me/admin/__assets__/js/main.js +60 -24
- data/lib/populate_me/admin/__assets__/js/quicksearch.js +1 -0
- data/lib/populate_me/admin/views/page.erb +5 -1
- data/lib/populate_me/document_mixins/admin_adapter.rb +2 -1
- data/lib/populate_me/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 514291d44eb8b068db7c98d742dc8395a5a2821255ac31ba054522823f6c55d9
|
4
|
+
data.tar.gz: 5a5c76cec480ed1c057ee70d33a38f21f1bd536c3ca5eabfdbbf2bf1d14c4b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72e7c460a58523cf8cd9a1e9dadba107f5bfa810ec552b93af0fe113d4bf98f0941cb168ac4323291ab5fee478c1d018ceaa017c2f4bf5ea3460ce6d0b4a4130
|
7
|
+
data.tar.gz: 41cf0a2e8705a2b184e3c840b001424cd4d69f00a447da72b89d2339ee0390a24b76c07e886b48127594ed73ad762e43560497097aa672dbc89ff2d7c9af2141
|
@@ -184,16 +184,20 @@ form {
|
|
184
184
|
margin-bottom: 1em;
|
185
185
|
}
|
186
186
|
|
187
|
-
input[type=text], input[type=email],
|
187
|
+
input[type=text], input[type=email], input[type=search],
|
188
188
|
textarea {
|
189
189
|
border: 0px;
|
190
190
|
color: #839496;
|
191
|
-
background: #ffffff;
|
191
|
+
background-color: #ffffff;
|
192
192
|
width: 400px;
|
193
193
|
padding: 0.5em;
|
194
194
|
font-size: 1em;
|
195
|
+
outline: 0;
|
196
|
+
}
|
197
|
+
input[type=text].search-items {
|
198
|
+
border-radius: 1em;
|
195
199
|
}
|
196
|
-
input[type=text]:focus, input[type=email]:focus,
|
200
|
+
input[type=text]:focus, input[type=email]:focus, input[type=email]:focus,
|
197
201
|
textarea:focus {
|
198
202
|
/* color: #002b36; */
|
199
203
|
}
|
@@ -45,14 +45,18 @@
|
|
45
45
|
root.busy = false;
|
46
46
|
root.on('push.columnav', function(e,data,cb) {
|
47
47
|
var $data = $("<li class='"+settings.column_class+"'>"+data+"</li>");
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
async function push_callback_stack() {
|
49
|
+
await root.append($data);
|
50
|
+
await new_column($data, root);
|
51
|
+
var cb_object = {event:e,column:$data,container:root,settings:settings};
|
52
|
+
await settings.on_push(cb_object);
|
53
|
+
if (typeof cb == 'function') await cb(cb_object);
|
52
54
|
root.busy = false;
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
root.find('> li:last-child').get(0).scrollIntoView({
|
56
|
+
behavior: 'smooth', inline: 'start'
|
57
|
+
});
|
58
|
+
}
|
59
|
+
push_callback_stack();
|
56
60
|
});
|
57
61
|
root.on('getandpush.columnav', function(e,url,cb) {
|
58
62
|
$.get(url, function(data) {
|
@@ -63,7 +67,7 @@
|
|
63
67
|
});
|
64
68
|
});
|
65
69
|
root.on('pop.columnav', function(e,removable,cb) {
|
66
|
-
removable = removable || root.
|
70
|
+
removable = removable || root.find('> li:last-child');
|
67
71
|
removable.css({visibility:'hidden'})
|
68
72
|
.animate({width:0},function(){
|
69
73
|
// Trick to make sure it runs only once
|
@@ -94,12 +94,24 @@ PopulateMe.make_sortable = function(selector,context) {
|
|
94
94
|
});
|
95
95
|
};
|
96
96
|
|
97
|
+
// Copy and restore column search.
|
98
|
+
// Used when saving pops the columns.
|
99
|
+
PopulateMe.copy_column_search = function(column) {
|
100
|
+
return column.find('.search-items').val();
|
101
|
+
};
|
102
|
+
PopulateMe.restore_column_search = function(column, value) {
|
103
|
+
if (value !== '' && column.data('qs')) {
|
104
|
+
column.find('.search-items').val(value);
|
105
|
+
column.data('qs').search(value);
|
106
|
+
}
|
107
|
+
};
|
108
|
+
|
97
109
|
// Scroll to an element, possibly in a specific column.
|
98
110
|
PopulateMe.scroll_to = function(el, column) {
|
99
111
|
if (!column) {
|
100
112
|
column = el.closest('.column');
|
101
113
|
}
|
102
|
-
|
114
|
+
el.get(0).scrollIntoView({ behavior: 'smooth'});
|
103
115
|
};
|
104
116
|
|
105
117
|
// Mark errors for report after form validation.
|
@@ -162,33 +174,54 @@ PopulateMe.jsValidationsPassed = function(context) {
|
|
162
174
|
// in case you have things to put in your custom javascript.
|
163
175
|
PopulateMe.init_column = function(c) {
|
164
176
|
|
177
|
+
var documents = $('.documents', c);
|
178
|
+
|
165
179
|
// Sort list item
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
180
|
+
if (documents.data('sort-field') !== '') {
|
181
|
+
PopulateMe.make_sortable(documents).bind('sortupdate', function(e, ui) {
|
182
|
+
var list = $(ui.item).closest('.documents');
|
183
|
+
var ids = list.children().map(function() {
|
184
|
+
return $(this).data().id;
|
185
|
+
}).get();
|
186
|
+
$.ajax({
|
187
|
+
url: list.data().sortUrl,
|
188
|
+
type: 'put',
|
189
|
+
data: {
|
190
|
+
action: 'sort',
|
191
|
+
field: list.data().sortField,
|
192
|
+
ids: ids
|
193
|
+
}
|
194
|
+
});
|
195
|
+
/*
|
196
|
+
ui.item contains the current dragged element.
|
197
|
+
ui.item.index() contains the new index of the dragged element
|
198
|
+
ui.oldindex contains the old index of the dragged element
|
199
|
+
ui.startparent contains the element that the dragged item comes from
|
200
|
+
ui.endparent contains the element that the dragged item was added to
|
201
|
+
*/
|
179
202
|
});
|
180
|
-
|
181
|
-
ui.item contains the current dragged element.
|
182
|
-
ui.item.index() contains the new index of the dragged element
|
183
|
-
ui.oldindex contains the old index of the dragged element
|
184
|
-
ui.startparent contains the element that the dragged item comes from
|
185
|
-
ui.endparent contains the element that the dragged item was added to
|
186
|
-
*/
|
187
|
-
});
|
203
|
+
}
|
188
204
|
|
189
205
|
// Sort nested documents
|
190
206
|
PopulateMe.make_sortable('.nested-documents',c);
|
191
207
|
|
208
|
+
$('.search-items', c).each(function() {
|
209
|
+
var field = $(this)
|
210
|
+
var qs = field.quicksearch($('.admin-list-item', c), {
|
211
|
+
selector: '.item-title',
|
212
|
+
onAfter: function() {
|
213
|
+
if (documents.is('.ui-sortable')) {
|
214
|
+
if (field.val() == '') {
|
215
|
+
documents.sortable('enable');
|
216
|
+
} else {
|
217
|
+
documents.sortable('disable');
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
});
|
222
|
+
c.data('qs', qs);
|
223
|
+
});
|
224
|
+
|
192
225
|
// Init textareas
|
193
226
|
$('textarea',c).trigger('input');
|
194
227
|
|
@@ -285,11 +318,14 @@ $(function() {
|
|
285
318
|
contentType: false,
|
286
319
|
success: function(res) {
|
287
320
|
if (res.success==true) {
|
288
|
-
var reloader = PopulateMe.finder.find('> li:nth-last-child(3) .selected')
|
321
|
+
var reloader = PopulateMe.finder.find('> li:nth-last-child(3) .selected');
|
289
322
|
if (reloader.size()>0) {
|
323
|
+
var reloadee = PopulateMe.finder.find('> li:nth-last-child(2)');
|
324
|
+
var current_search = PopulateMe.copy_column_search(reloadee);
|
290
325
|
reloader.trigger('click.columnav',[function(cb_object) {
|
291
|
-
var target = $('[data-id='+res.data.
|
326
|
+
var target = $('[data-id='+res.data._id+']', cb_object.column);
|
292
327
|
if (target.size()>0) {
|
328
|
+
PopulateMe.restore_column_search(cb_object.column, current_search);
|
293
329
|
PopulateMe.scroll_to(target, cb_object.column);
|
294
330
|
}
|
295
331
|
}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
(function($,window,document,undefined){$.fn.quicksearch=function(target,opt){var timeout,cache,rowcache,jq_results,val="",e=this,options=$.extend({delay:100,selector:null,stripeRows:null,loader:null,noResults:"",matchedResultsCount:0,bind:"keyup",onBefore:function(){return},onAfter:function(){return},show:function(){this.style.display=""},hide:function(){this.style.display="none"},prepareQuery:function(val){return val.toLowerCase().split(" ")},testQuery:function(query,txt,_row){for(var i=0;i<query.length;i+=1){if(txt.indexOf(query[i])===-1){return false}}return true}},opt);this.go=function(){var i=0,numMatchedRows=0,noresults=true,query=options.prepareQuery(val),val_empty=val.replace(" ","").length===0;for(var i=0,len=rowcache.length;i<len;i++){if(val_empty||options.testQuery(query,cache[i],rowcache[i])){options.show.apply(rowcache[i]);noresults=false;numMatchedRows++}else{options.hide.apply(rowcache[i])}}if(noresults){this.results(false)}else{this.results(true);this.stripe()}this.matchedResultsCount=numMatchedRows;this.loader(false);options.onAfter();return this};this.search=function(submittedVal){val=submittedVal;e.trigger()};this.currentMatchedResults=function(){return this.matchedResultsCount};this.stripe=function(){if(typeof options.stripeRows==="object"&&options.stripeRows!==null){var joined=options.stripeRows.join(" ");var stripeRows_length=options.stripeRows.length;jq_results.not(":hidden").each(function(i){$(this).removeClass(joined).addClass(options.stripeRows[i%stripeRows_length])})}return this};this.strip_html=function(input){var output=input.replace(new RegExp("<[^<]+>","g"),"");output=$.trim(output.toLowerCase());return output};this.results=function(bool){if(typeof options.noResults==="string"&&options.noResults!==""){if(bool){$(options.noResults).hide()}else{$(options.noResults).show()}}return this};this.loader=function(bool){if(typeof options.loader==="string"&&options.loader!==""){bool?$(options.loader).show():$(options.loader).hide()}return this};this.cache=function(){jq_results=$(target);if(typeof options.noResults==="string"&&options.noResults!==""){jq_results=jq_results.not(options.noResults)}var t=typeof options.selector==="string"?jq_results.find(options.selector):$(target).not(options.noResults);cache=t.map(function(){return e.strip_html(this.innerHTML)});rowcache=jq_results.map(function(){return this});val=val||this.val()||"";return this.go()};this.trigger=function(){this.loader(true);options.onBefore();window.clearTimeout(timeout);timeout=window.setTimeout(function(){e.go()},options.delay);return this};this.cache();this.results(true);this.stripe();this.loader(false);return this.each(function(){$(this).on(options.bind,function(){val=$(this).val();e.trigger()})})}})(jQuery,this,document);
|
@@ -46,6 +46,9 @@
|
|
46
46
|
{{/is_polymorphic}}
|
47
47
|
<a href="<%= request.script_name %>/form/{{dasherized_class_name}}{{#new_data}}?{{new_data}}{{/new_data}}" class='column-push new-document-btn' title='Create'>+</a>
|
48
48
|
</p>
|
49
|
+
<form class='form-search-items'>
|
50
|
+
<input type='text' class='search-items' placeholder='Search'>
|
51
|
+
</form>
|
49
52
|
<ol class='documents {{#grid_view}}grid{{/grid_view}}' data-sort-field='{{sort_field}}' data-sort-url='<%= request.script_name %>/api/{{dasherized_class_name}}'>
|
50
53
|
{{#items}}{{#custom_partial_or_default}}template_document{{/custom_partial_or_default}}{{/items}}
|
51
54
|
</ol>
|
@@ -57,7 +60,7 @@
|
|
57
60
|
<button type='button' class='admin-delete' title='Delete' value='<%= request.script_name %>/api/{{admin_url}}'>×</button>
|
58
61
|
</header>
|
59
62
|
<a href="<%= request.script_name %>/form/{{admin_url}}" class='column-push' title='Edit'>
|
60
|
-
{{title}}
|
63
|
+
<span class='item-title'>{{title}}</span>
|
61
64
|
{{#image_url}}
|
62
65
|
<br />
|
63
66
|
<img src='{{image_url}}{{cache_buster}}' alt='{{title}}' width='300' />
|
@@ -176,6 +179,7 @@
|
|
176
179
|
<script src="<%= request.script_name %>/__assets__/js/columnav.js" type="text/javascript" charset="utf-8"></script>
|
177
180
|
<%# <script src="<%= request.script_name %1>/__assets__/js/sortable.js" type="text/javascript" charset="utf-8"></script> %>
|
178
181
|
<script src="<%= request.script_name %>/__assets__/js/asmselect.js" type="text/javascript" charset="utf-8"></script>
|
182
|
+
<script src="<%= request.script_name %>/__assets__/js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
179
183
|
<script type="text/javascript">
|
180
184
|
window.admin_path = "<%= request.script_name %>";
|
181
185
|
window.index_path = "<%= settings.index_path %>";
|
@@ -124,6 +124,7 @@ module PopulateMe
|
|
124
124
|
end
|
125
125
|
new_data = Rack::Utils.build_nested_query(data: o[:params][:filter])
|
126
126
|
end
|
127
|
+
items = self.admin_find(query: query)
|
127
128
|
{
|
128
129
|
template: 'template_list',
|
129
130
|
grid_view: self.settings[:grid_view]==true,
|
@@ -135,7 +136,7 @@ module PopulateMe
|
|
135
136
|
sort_field: self.sort_field_for(o),
|
136
137
|
# 'command_plus'=> !self.populate_config[:no_plus],
|
137
138
|
# 'command_search'=> !self.populate_config[:no_search],
|
138
|
-
items:
|
139
|
+
items: items.map do |d|
|
139
140
|
d.to_admin_list_item(o)
|
140
141
|
end
|
141
142
|
}
|
data/lib/populate_me/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: populate-me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickael Riga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: web-utils
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- lib/populate_me/admin/__assets__/js/jquery-ui.min.js
|
217
217
|
- lib/populate_me/admin/__assets__/js/main.js
|
218
218
|
- lib/populate_me/admin/__assets__/js/mustache.js
|
219
|
+
- lib/populate_me/admin/__assets__/js/quicksearch.js
|
219
220
|
- lib/populate_me/admin/__assets__/js/sortable.js
|
220
221
|
- lib/populate_me/admin/views/help.erb
|
221
222
|
- lib/populate_me/admin/views/page.erb
|