Skip to content

Commit 66eecfc

Browse files
committed
Merge pull request #395 from UNC-Libraries/custom-colls-followup2
Added null check when setting the list of views in CollectionSettings…
2 parents 466502f + 38b576d commit 66eecfc

File tree

4 files changed

+49
-9
lines changed

4 files changed

+49
-9
lines changed

admin/src/main/java/edu/unc/lib/dl/admin/controller/EditCollectionSettingsController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class EditCollectionSettingsController {
6666
@Autowired
6767
private SolrQueryLayerService solrQueryService;
6868

69-
private final String defaultDefaultTab = ContainerView.DESCRIPTION.name();
69+
private final String defaultDefaultTab = ContainerView.STRUCTURE.name();
7070
private final List<String> defaultTabList = Arrays.asList(ContainerView.DESCRIPTION.name(),
7171
ContainerView.STRUCTURE.name(), ContainerView.EXPORTS.name());
7272

metadata/src/main/java/edu/unc/lib/dl/model/ContainerSettings.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public List<String> getViews() {
7474
}
7575

7676
public void setViews(List<String> views) {
77+
if (views == null) {
78+
this.views = null;
79+
return;
80+
}
81+
7782
this.views = new ArrayList<>(views.size());
7883
for (ContainerView view : ContainerView.values()) {
7984
if (views.contains(view.name())) {
@@ -87,13 +92,14 @@ public String getViewDisplayName(String view) {
8792
return viewEnum == null? null : viewEnum.getDisplayName();
8893
}
8994

90-
public Map<String, Map<String, String>> getViewInfo() {
91-
Map<String, Map<String, String>> result = new LinkedHashMap<>();
95+
public Map<String, Map<String, Object>> getViewInfo() {
96+
Map<String, Map<String, Object>> result = new LinkedHashMap<>();
9297

9398
for (ContainerView view : ContainerView.values()) {
94-
Map<String, String> entry = new HashMap<>();
99+
Map<String, Object> entry = new HashMap<>();
95100
entry.put("displayName", view.getDisplayName());
96101
entry.put("description", view.getDescription());
102+
entry.put("required", new Boolean(view.isRequired()));
97103

98104
result.put(view.name(), entry);
99105
}
@@ -107,14 +113,22 @@ public static enum ContainerView {
107113
LIST_CONTENTS("List Contents", "A result view of files within this collection with hierarchy flattened"),
108114
DEPARTMENTS("Departments", "A list of the departments associated with objects in this collection"),
109115
DESCRIPTION("Description", "An overview of the contents of the collection and descriptive metadata"),
110-
EXPORTS("Metadata", "Export options for data associated with this collection.");
116+
EXPORTS("Metadata", "Export options for data associated with this collection.", true);
111117

112118
String displayName;
113119
String description;
120+
boolean required;
114121

115122
private ContainerView(String displayName, String description) {
116123
this.displayName = displayName;
117124
this.description = description;
125+
this.required = false;
126+
}
127+
128+
private ContainerView(String displayName, String description, boolean required) {
129+
this.displayName = displayName;
130+
this.description = description;
131+
this.required = required;
118132
}
119133

120134
public String getDisplayName() {
@@ -124,5 +138,9 @@ public String getDisplayName() {
124138
public String getDescription() {
125139
return description;
126140
}
141+
142+
public boolean isRequired() {
143+
return required;
144+
}
127145
}
128146
}

static/css/admin/admin_forms.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
margin: 0;
276276
text-indent: 0;
277277
color: #333;
278+
cursor: pointer;
278279
}
279280

280281
.selectable_multi li span {
@@ -295,6 +296,11 @@
295296
.selectable_multi .selected:hover {
296297
background-color: #f8f8ff;
297298
}
299+
300+
.selectable_multi .disabled {
301+
color: #888;
302+
cursor: default;
303+
}
298304

299305
.selectable_multi_actions {
300306
width: 40%;

static/js/admin/src/action/EditCollectionSettingsAction.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define('EditCollectionSettingsAction', ['jquery', 'underscore', 'RemoteStateChan
88
EditCollectionSettingsAction.prototype.execute = function() {
99
var self = this;
1010

11-
this.dialog = $("<div class='containingDialog'>Loading...</div>");
11+
this.dialog = $("<div class='containingDialog'></div>");
1212
this.dialog.dialog({
1313
autoOpen: true,
1414
width: '560',
@@ -17,6 +17,13 @@ define('EditCollectionSettingsAction', ['jquery', 'underscore', 'RemoteStateChan
1717
title: "Collection Settings"
1818
});
1919

20+
var loadingOverlay = new ModalLoadingOverlay(this.dialog, {
21+
autoOpen : false,
22+
type : 'icon',
23+
dialog : self.dialog
24+
});
25+
loadingOverlay.open();
26+
2027
$.ajax({
2128
url : "editCollection/" + this.context.target.pid,
2229
type : "GET"
@@ -27,6 +34,9 @@ define('EditCollectionSettingsAction', ['jquery', 'underscore', 'RemoteStateChan
2734
// Recenter the dialog
2835
self.dialog.dialog("option", "position", "center");
2936

37+
// Clear out the initial loading overlay
38+
loadingOverlay.remove();
39+
3040
self.$form = self.dialog.first();
3141
var defaultViewSelect = $("#full_record_default_view", self.$form);
3242

@@ -50,6 +60,9 @@ define('EditCollectionSettingsAction', ['jquery', 'underscore', 'RemoteStateChan
5060
}
5161

5262
function toggleChecked(checkbox, checked) {
63+
if (checkbox.prop("disabled")) {
64+
return;
65+
}
5366
if (checked === undefined) {
5467
checked = !checkbox.prop("checked");
5568
}
@@ -73,9 +86,13 @@ define('EditCollectionSettingsAction', ['jquery', 'underscore', 'RemoteStateChan
7386
}
7487

7588
// Mark starting selected views
76-
$.each(collectionSettings.viewInfo, function(viewKey) {
89+
$.each(collectionSettings.viewInfo, function(viewKey, viewInfo) {
7790
var checkbox = $("#full_record_views_select li[data-viewid='" + viewKey + "']", self.$form).find("input");
78-
toggleChecked(checkbox, $.inArray(viewKey, collectionSettings.views) != -1);
91+
var checked = viewInfo.required || $.inArray(viewKey, collectionSettings.views) != -1;
92+
toggleChecked(checkbox, checked);
93+
if (viewInfo.required) {
94+
checkbox.prop("disabled", true).parent("li").first().addClass("disabled");
95+
}
7996
});
8097

8198
// Enable help text
@@ -96,7 +113,6 @@ define('EditCollectionSettingsAction', ['jquery', 'underscore', 'RemoteStateChan
96113
var overlay = new ModalLoadingOverlay(self.$form, {
97114
autoOpen : false,
98115
type : 'icon',
99-
text : 'updating...',
100116
dialog : self.dialog
101117
});
102118
overlay.open();

0 commit comments

Comments
 (0)