populate-me 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aae26b6056ce44152b109789786ed2e364c224c8b909944ccd331ce7cacb687b
|
4
|
+
data.tar.gz: 907b296590c89a4182b2ee7ebeb68db302a867f2c611d9e11f527848f4b030fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ee5f83a895efc0ce9b8a9b7ac0122e7e0ff9489cb19f2ffda038717eb4abea556dca1b1a7a369446d9fa1cad6e9bca91a511596f6c1d8de20b354d0587e6fed
|
7
|
+
data.tar.gz: c00b2f1dce9f4abf97dffb956ed5d8620eaca3b4f76d4a58885c6f45ba7efe18aa4857e000ab81fbb8e4c705ce27fb5ec8c60cd9297b9d2cb38616bc85051e82
|
data/README.md
CHANGED
@@ -79,6 +79,7 @@ Available types are:
|
|
79
79
|
- `:text` Multiline text.
|
80
80
|
- `:boolean` Which is `true` or `false`.
|
81
81
|
- `:select` Dropdown list of options (records a string).
|
82
|
+
- `:lnglat` Coordinates field of the form "Longitude, Latitude" with a Mapbox interface.
|
82
83
|
|
83
84
|
A `:list` type exists as well for nested documents, but it is not
|
84
85
|
fully working yet.
|
@@ -214,6 +214,32 @@ PopulateMe.jsValidationsPassed = function(context) {
|
|
214
214
|
return true;
|
215
215
|
};
|
216
216
|
|
217
|
+
PopulateMe.lngLatRegex = /^[-+]?([0-9]*[.])?[0-9]+\s*,\s*[-+]?([0-9]*[.])?[0-9]+$/;
|
218
|
+
|
219
|
+
PopulateMe.isLngLatString = function(str) {
|
220
|
+
return typeof str === 'string' && str.match( PopulateMe.lngLatRegex );
|
221
|
+
};
|
222
|
+
|
223
|
+
PopulateMe.defaultLngLat = {
|
224
|
+
lng: -0.07820128620232675,
|
225
|
+
lat: 51.52270386882307
|
226
|
+
};
|
227
|
+
|
228
|
+
PopulateMe.parseLngLat = function(str) {
|
229
|
+
if ( !PopulateMe.isLngLatString( str ) ) {
|
230
|
+
return PopulateMe.defaultLngLat;
|
231
|
+
}
|
232
|
+
var atoms = str.split(/\s*,\s*/);
|
233
|
+
return {
|
234
|
+
lng: parseFloat( atoms[0] ),
|
235
|
+
lat: parseFloat( atoms[1] )
|
236
|
+
};
|
237
|
+
};
|
238
|
+
|
239
|
+
PopulateMe.lngLatString = function( lnglat ) {
|
240
|
+
return lnglat.lng + ', ' + lnglat.lat;
|
241
|
+
};
|
242
|
+
|
217
243
|
// Init column
|
218
244
|
// Bind events and init things that need to happen when
|
219
245
|
// a new column is added to the finder.
|
@@ -221,7 +247,7 @@ PopulateMe.jsValidationsPassed = function(context) {
|
|
221
247
|
// in case you have things to put in your custom javascript.
|
222
248
|
PopulateMe.init_column = function(c) {
|
223
249
|
|
224
|
-
var documents = $('.documents', c);
|
250
|
+
var documents = $('.documents', c);
|
225
251
|
|
226
252
|
// Sort list item
|
227
253
|
if (documents.data('sort-field') !== '') {
|
@@ -306,6 +332,42 @@ PopulateMe.init_column = function(c) {
|
|
306
332
|
link.attr('href', PopulateMe.update_query_parameter(link.attr('href'), 'data[polymorphic_type]', $this.val()));
|
307
333
|
}).change();
|
308
334
|
|
335
|
+
// LngLat fields
|
336
|
+
$('.lnglat-input', c).each( function( index, input ) {
|
337
|
+
var $input = $(input);
|
338
|
+
var $map = $( "<div class='map'></div>" );
|
339
|
+
$input.before( $map );
|
340
|
+
var map = new mapboxgl.Map({
|
341
|
+
container: $map.get(0),
|
342
|
+
// Choose from Mapbox's core styles, or make your own style with Mapbox Studio
|
343
|
+
style: 'mapbox://styles/mapbox/streets-v12',
|
344
|
+
center: PopulateMe.defaultLngLat,
|
345
|
+
doubleClickZoom: false,
|
346
|
+
zoom: 10
|
347
|
+
});
|
348
|
+
var marker;
|
349
|
+
var currentLngLat;
|
350
|
+
function mapReadsField( mapCenter) {
|
351
|
+
mapCenter = typeof mapCenter !== 'undefined' ? mapCenter : true;
|
352
|
+
if ( marker ) marker.remove();
|
353
|
+
if ( PopulateMe.isLngLatString( $input.val() ) ) {
|
354
|
+
currentLngLat = PopulateMe.parseLngLat( $input.val() );
|
355
|
+
marker = new mapboxgl.Marker({ color: 'black' })
|
356
|
+
.setLngLat( currentLngLat )
|
357
|
+
.addTo(map);
|
358
|
+
} else {
|
359
|
+
currentLngLat = PopulateMe.defaultLngLat;
|
360
|
+
}
|
361
|
+
if ( mapCenter ) map.setCenter( currentLngLat )
|
362
|
+
};
|
363
|
+
mapReadsField();
|
364
|
+
$input.change( mapReadsField );
|
365
|
+
map.on('click', function(e) {
|
366
|
+
$input.val( PopulateMe.lngLatString( e.lngLat ) );
|
367
|
+
mapReadsField( false );
|
368
|
+
});
|
369
|
+
});
|
370
|
+
|
309
371
|
// Warning when date input not supported
|
310
372
|
var dateFields = $('[type="date"]', c);
|
311
373
|
if ( dateFields.size()>0 && dateFields.prop('type') != 'date' ) {
|
@@ -7,6 +7,7 @@
|
|
7
7
|
<link href="<%= request.script_name %>/__assets__/img/favicon.png" rel="icon" type="image/png">
|
8
8
|
<link rel="stylesheet" href="<%= request.script_name %>/__assets__/css/jquery-ui.min.css" type="text/css" media='screen' />
|
9
9
|
<link rel="stylesheet" href="<%= request.script_name %>/__assets__/css/asmselect.css" type="text/css" media='screen' />
|
10
|
+
<link href="https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.css" rel="stylesheet">
|
10
11
|
<link rel="stylesheet" href="<%= request.script_name %>/__assets__/css/main.css" type="text/css" media='screen' />
|
11
12
|
<% if settings.respond_to? :custom_css_url %>
|
12
13
|
<link rel="stylesheet" href="<%= settings.custom_css_url %>" type="text/css" media='screen' />
|
@@ -125,7 +126,7 @@
|
|
125
126
|
{{#adapted_field}}{{/adapted_field}}
|
126
127
|
{{/wrap}}
|
127
128
|
</script>
|
128
|
-
|
129
|
+
|
129
130
|
<script id="template-string-field" type="x-tmpl-mustache">
|
130
131
|
<input name='{{input_name}}' value='{{input_value}}' {{#required}}required{{/required}}{{{build_input_attributes}}} {{#autocomplete.length}}list='datalist-{{id}}'{{/autocomplete.length}} />
|
131
132
|
{{#autocomplete.length}}
|
@@ -137,6 +138,10 @@
|
|
137
138
|
{{/autocomplete.length}}
|
138
139
|
</script>
|
139
140
|
|
141
|
+
<script id="template-lnglat-field" type="x-tmpl-mustache">
|
142
|
+
<input class='lnglat-input' name='{{input_name}}' value='{{input_value}}' {{#required}}required{{/required}}{{{build_input_attributes}}} pattern="^[-+]?([0-9]*[.])?[0-9]+\s*,\s*[-+]?([0-9]*[.])?[0-9]+$" placeholder="Longitude, Latitude" />
|
143
|
+
</script>
|
144
|
+
|
140
145
|
<script id="template-text-field" type="x-tmpl-mustache">
|
141
146
|
<textarea name='{{input_name}}' {{#required}}required{{/required}}{{{build_input_attributes}}}>{{input_value}}</textarea>
|
142
147
|
</script>
|
@@ -197,7 +202,9 @@
|
|
197
202
|
<%# <script src="<%= request.script_name %1>/__assets__/js/sortable.js" type="text/javascript" charset="utf-8"></script> %>
|
198
203
|
<script src="<%= request.script_name %>/__assets__/js/asmselect.js" type="text/javascript" charset="utf-8"></script>
|
199
204
|
<script src="<%= request.script_name %>/__assets__/js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
205
|
+
<script src="https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.js"></script>
|
200
206
|
<script type="text/javascript">
|
207
|
+
mapboxgl.accessToken = "pk.eyJ1IjoibWlja2FlbHJpZ2EiLCJhIjoiY2xsYXA3Y25lMWIxNzNlbzY0MW1hdm15ZCJ9.bBJwnlHVNkPyF-ZKA5J6Dg";
|
201
208
|
window.admin_path = "<%= request.script_name %>";
|
202
209
|
window.index_path = "<%= settings.index_path %>";
|
203
210
|
</script>
|
data/lib/populate_me/version.rb
CHANGED
data/test/test_s3_attachment.rb
CHANGED
@@ -99,6 +99,14 @@ describe 'PopulateMe::S3Attachment' do
|
|
99
99
|
file.unlink
|
100
100
|
end
|
101
101
|
|
102
|
+
it "Can have filenames with accents" do
|
103
|
+
uploaded_file = Rack::Multipart::UploadedFile.new('test/Léonidas.txt')
|
104
|
+
book = S3Book.new
|
105
|
+
|
106
|
+
attachment = book.attachment(:content)
|
107
|
+
assert_equal 'yo', attachment.next_available_filename(uploaded_file.original_filename)
|
108
|
+
end
|
109
|
+
|
102
110
|
it "Can override the url_prefix at document class level" do
|
103
111
|
file = Tempfile.new('foo')
|
104
112
|
book = S3BookNoPrefix.new
|
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.21.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: 2023-
|
11
|
+
date: 2023-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: web-utils
|