-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
batch_ops.js
106 lines (93 loc) · 2.84 KB
/
batch_ops.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*globals define: true, requirejs: true */
'use strict';
requirejs.config({
config: {
text: {
useXhr: function (url, protocol, hostname, port) {
// allow cross-domain requests
// remote server allows CORS
return true;
}
},
waitSeconds: 5
},
baseUrl: staticUrl + 'lib/js',
shim: {
'underscore': { exports: '_'}
},
paths: {
'upload': '../../geonode/js/upload',
'templates': '../../geonode/js/templates',
'progress': 'jquery.ajax-progress'
}
});
define(['jquery'],function($){
return {
batch_delete: function() {
var form = $(this);
var action = form.attr("action");
var postdata = {
layers: [],
maps: []
};
var selected = $(".asset-selector:checked");
$.each(selected, function(index, value) {
var el = $(value);
if (el.data("type") === "map") {
postdata.maps.push(el.data("id"));
} else if (el.data("type") === "layer") {
postdata.layers.push(el.data("id"));
}
});
if (!postdata.layers.length) {
delete postdata.layers;
}
if (!postdata.maps.length) {
delete postdata.maps;
}
$.ajax({
type: "POST",
url: action,
data: JSON.stringify(postdata),
success: function(data) {
$("#delete_form").modal("hide");
}
});
return false;
},
batch_perms_submit: function() {
var form = $(this);
var action = form.attr("action");
var postdata = {
layers: [],
maps: [],
permissions: {}
};
var selected = $(".asset-selector:checked");
$.each(selected, function(index, value) {
var el = $(value);
if (el.data("type") === "map") {
postdata.maps.push(el.data("id"));
} else if (el.data("type") === "layer") {
postdata.layers.push(el.data("id"));
}
});
if (!postdata.layers.length) {
delete postdata.layers;
}
if (!postdata.maps.length) {
delete postdata.maps;
}
postdata.permissions = permissionsString(form, "bulk");
$.ajax({
type: "POST",
url: action,
data: JSON.stringify(postdata),
success: function(data) {
$("#modal_perms").modal("hide");
}
});
return false;
}
}
});