aboutsummaryrefslogtreecommitdiffstats
path: root/lib/toaster/toastergui/templates/layers_dep_modal.html
diff options
context:
space:
mode:
Diffstat (limited to 'lib/toaster/toastergui/templates/layers_dep_modal.html')
-rw-r--r--lib/toaster/toastergui/templates/layers_dep_modal.html48
1 files changed, 35 insertions, 13 deletions
diff --git a/lib/toaster/toastergui/templates/layers_dep_modal.html b/lib/toaster/toastergui/templates/layers_dep_modal.html
index 821bbda29..b03fd0b21 100644
--- a/lib/toaster/toastergui/templates/layers_dep_modal.html
+++ b/lib/toaster/toastergui/templates/layers_dep_modal.html
@@ -3,10 +3,10 @@
<form id="dependencies_modal_form">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
- <h3><span class="layer-name"></span> dependencies</h3>
+ <h3><span id="title"></span> dependencies</h3>
</div>
<div class="modal-body">
- <p><strong class="layer-name"></strong> depends on some layers that are not added to your project. Select the ones you want to add:</p>
+ <p id="body-text"> <strong id="layer-name"></strong> depends on some layers that are not added to your project. Select the ones you want to add:</p>
<ul class="unstyled" id="dependencies_list">
</ul>
</div>
@@ -18,9 +18,20 @@
</div>
<script>
-function show_layer_deps_modal(projectId, layer, dependencies, successAdd) {
+function show_layer_deps_modal(projectId, layer, dependencies, title, body, addToProject, successAdd) {
// update layer name
- $('.layer-name').text(layer.name);
+ if (title) {
+ $('#dependencies_modal #title').text(title);
+ } else {
+ $('#dependencies_modal #title').text(layer.name);
+ }
+
+ if (body) {
+ $("#dependencies_modal #body-text").html(body);
+ } else {
+ $("#dependencies_modal #layer-name").text(layer.name);
+ }
+
var deplistHtml = "";
for (var i = 0; i < dependencies.length; i++) {
deplistHtml += "<li><label class=\"checkbox\"><input name=\"dependencies\" value=\"";
@@ -31,7 +42,13 @@ function show_layer_deps_modal(projectId, layer, dependencies, successAdd) {
}
$('#dependencies_list').html(deplistHtml);
- var selected = [layer.id];
+ var selected = [];
+ /* -1 is a special dummy Id which we use when the layer isn't yet in the
+ * system, normally we would add the current layer to the selection.
+ */
+ if (layer.id != -1)
+ selected.push(layer.id);
+
var layer_link_list = "<a href='"+layer.url+"'>"+layer.name+"</a>";
$("#dependencies_modal_form").submit(function (e) {
@@ -54,15 +71,20 @@ function show_layer_deps_modal(projectId, layer, dependencies, successAdd) {
$('#dependencies_modal').modal('hide');
- var editProjectUrl = "{% url 'xhr_projectedit' project.id %}";
- libtoaster.editProject(editProjectUrl, projectId, { 'layerAdd': selected.join(",") }, function () {
- if (successAdd) {
- successAdd(selected);
- }
- }, function () {
- console.log ("Adding layers to project failed");
- });
+ if (addToProject) {
+ var editProjectUrl = "{% url 'xhr_projectedit' project.id %}";
+ libtoaster.editProject(editProjectUrl, projectId, { 'layerAdd': selected.join(",") }, function () {
+ if (successAdd) {
+ successAdd(selected);
+ }
+ }, function () {
+ console.log ("Adding layers to project failed");
+ });
+ } else {
+ successAdd(selected);
+ }
});
+
$('#dependencies_modal').modal('show');
}
</script>