Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions layers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,41 @@ def orders(self):
content_type = ContentType.objects.get_for_model(self.__class__)
return ChildOrder.objects.filter(object_id=self.id, content_type=content_type)

@property
def layers(self):
"""
Returns an array of all of the Layer records that are direct children of this Theme.
Helps 'get_portal_catalog_map' view identify 'visualizable' layers in the catalog
"""
content_type = ContentType.objects.get_for_model(Layer)
child_orders = ChildOrder.objects.filter(parent_theme=self, content_type=content_type).order_by('order', 'id')
layers = [
child_order.content_object
for child_order in child_orders
if child_order.content_object.is_visible
]
return layers

@property
def all_layers(self):
"""
Returns an array of all of the Layer records that are descendants of this Theme.
Helps the 'get_portal_catalog_map' view to identify 'visualizable' layers in the catalog.
"""
content_type = ContentType.objects.get_for_model(Theme)
child_theme_orders = ChildOrder.objects.filter(parent_theme=self, content_type=content_type).order_by('order', 'id')
layers = self.layers
for child_order in child_theme_orders:
if child_order.content_object.is_visible:
layers = layers + child_order.content_object.all_layers
Comment thread
rhodges marked this conversation as resolved.

unique_layers = []
seen_layer_pks = set()
for layer in layers:
if layer.pk not in seen_layer_pks:
seen_layer_pks.add(layer.pk)
unique_layers.append(layer)
return unique_layers
# return dict formatted for use in bootstrap-3-typeahead 'layer search' widget in 'visualize'
# overrides ChildType method to include any 'sublayer' information.
def get_search_object(self, site_id, parent_theme):
Expand Down
15 changes: 7 additions & 8 deletions layers/static/admin/js/layer_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ document.addEventListener("DOMContentLoaded", function() {

});

const layerTypeField = document.querySelector("#id_layer_type");
if (layerTypeField) {
layerTypeField.addEventListener("change", updateInlines);
updateInlines();
assign_field_values_from_source_technology();
}

assign_field_values_from_source_technology = function() {
if ($('#id_layer_type').val() == "ArcRest" || $('#id_layer_type').val() == "ArcFeatureServer") {
var url = $('#id_url').val();
Expand Down Expand Up @@ -91,5 +84,11 @@ document.addEventListener("DOMContentLoaded", function() {
}
}
}
assign_field_values_from_source_technology()

const layerTypeField = document.querySelector("#id_layer_type");
if (layerTypeField) {
layerTypeField.addEventListener("change", updateInlines);
updateInlines();
assign_field_values_from_source_technology();
}
});
5 changes: 5 additions & 0 deletions layers/static/admin/layers/css/layer_form.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ fieldset.late-transition.collapse * {
}
fieldset.late-transition.collapse *:not(.related-widget-wrapper):not(.related-widget-wrapper *) {
height: auto;
max-width: 100%;
}

fieldset.late-transition.collapse span.select2-selection__rendered:not(.related-widget-wrapper):not(.related-widget-wrapper *) {
min-height: 1.5rem;
}

fieldset.late-transition.collapse div.argis-details-table-wrapper,
Expand Down
11 changes: 11 additions & 0 deletions layers/static/layers/js/catalog/GeoPortal2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
//
////////////////////////////////////////////////////////////////////////////////

const union = function (array1, array2) {
var hash = {}, union_arr = [];
$.each($.merge($.merge([], array1), array2), function (index, value) { hash[value] = value; });
$.each(hash, function (key, value) { union_arr.push(key); });
return union_arr;
}

var populate_fields_from_catalog = function (catalog_record_data, record_id) {
if (record_id == null || record_id == "null") {
Expand All @@ -25,6 +31,11 @@ var populate_fields_from_catalog = function (catalog_record_data, record_id) {
record_json = data._source;
record_json.id = data._id;
aggregate_catalog_record_values(record_json);
},
error: function (error) {
console.error("Error retrieving catalog record: " + error);
// AdminLayerForm.replace_all_select2_with_input();
hide_spinner();
}
});
}
Expand Down
1 change: 0 additions & 1 deletion layers/templates/admin/layers/Layer/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<script type="text/javascript" src="{% static 'jquery/dist/jquery.min.js' %}"></script>
<script src="{% static 'jquery-ui/jquery-ui.min.js' %}"></script>
<script src="{% static 'admin/js/vendor/select2/select2.full.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/lib/knockout-3.3.0.js' %}"></script>
<script type="text/javascript">
CATALOG_TECHNOLOGY = '{{ CATALOG_TECHNOLOGY }}';
CATALOG_PROXY = '{{ CATALOG_PROXY }}';
Expand Down
1 change: 0 additions & 1 deletion layers/templates/admin/layers/Theme/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<script type="text/javascript" src="{% static 'jquery/dist/jquery.min.js' %}"></script>
<script src="{% static 'jquery-ui/jquery-ui.min.js' %}"></script>
<script src="{% static 'admin/js/vendor/select2/select2.full.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/lib/knockout-3.3.0.js' %}"></script>

<script type="text/javascript">
CATALOG_TECHNOLOGY = '{{ CATALOG_TECHNOLOGY|default:"default" }}';
Expand Down
Loading