add display filter (active/disabled) to IndexSchema_p.html config

for easier overview of schema fields
pull/1/head
reger 11 years ago
parent d4f65833a1
commit 312972c586

@ -36,7 +36,11 @@
<td>Active</td>
<td>Attribute</td>
<td>Custom Solr Field Name</td>
<td>Comment</td>
<td>Comment <div style="float: right" class="btn-group btn-group-xs">
<button type="submit" class="btn btn-default #(activeonly)#::active#(/activeonly)#" name="filter" value="active">show active</button>
<button type="submit" class="btn btn-default #(viewall)#::active#(/viewall)#">show all available</button>
<button type="submit" class="btn btn-default #(disabledonly)#::active#(/disabledonly)#" name="filter" value="disabled">show disabled</button></div>
</td>
</tr>
#{schema}#
<tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#">

@ -51,21 +51,24 @@ public class IndexSchema_p {
boolean modified = false; // flag to remember changes
while (i.hasNext()) {
entry = i.next();
final String v = post.get("schema_" + entry.key());
final String sfn = post.get("schema_solrfieldname_" + entry.key());
if (sfn != null ) {
// set custom solr field name
if (!sfn.equals(entry.getValue())) {
entry.setValue(sfn);
if (post.containsKey("schema_solrfieldname_" + entry.key()) ) { // can't use schem_... checkbox only contained if checked
// only handle displayed (contained) fields
final String v = post.get("schema_" + entry.key());
final String sfn = post.get("schema_solrfieldname_" + entry.key());
if (sfn != null) {
// set custom solr field name
if (!sfn.equals(entry.getValue())) {
entry.setValue(sfn);
modified = true;
}
}
// set enable flag
final boolean c = v != null && v.equals("checked");
if (entry.enabled() != c) {
entry.setEnable(c);
modified = true;
}
}
// set enable flag
final boolean c = v != null && v.equals("checked");
if (entry.enabled() != c) {
entry.setEnable(c);
modified = true;
}
}
}
if (modified) { // save settings to config file if modified
try {
@ -102,13 +105,25 @@ public class IndexSchema_p {
boolean dark = false;
// use enum SolrField to keep defined order
SchemaDeclaration[] cc = schemaName.equals(CollectionSchema.CORE_NAME) ? CollectionSchema.values() : WebgraphSchema.values();
String filterstr = null;
// set active filter button property
boolean viewall = (post == null) || (filterstr = post.get("filter")) == null;
boolean viewactiveonly = !viewall && "active".equals(filterstr);
boolean viewdisabledonly = !viewall && "disabled".equals(filterstr);
prop.put("viewall",viewall);
prop.put("activeonly", viewactiveonly);
prop.put("disabledonly", viewdisabledonly);
for(SchemaDeclaration field : cc) {
prop.put("schema_" + c + "_dark", dark ? 1 : 0); dark = !dark;
prop.put("schema_" + c + "_checked", cs.contains(field.name()) ? 1 : 0);
prop.putHTML("schema_" + c + "_key", field.name());
prop.putHTML("schema_" + c + "_solrfieldname",field.name().equalsIgnoreCase(field.getSolrFieldName()) ? "" : field.getSolrFieldName());
if (field.getComment() != null) prop.putHTML("schema_" + c + "_comment",field.getComment());
c++;
boolean showline = viewactiveonly ? cs.contains(field.name()) : (viewdisabledonly ? cs.containsDisabled(field.name()): true);
if (showline) {
prop.put("schema_" + c + "_dark", dark ? 1 : 0); dark = !dark;
prop.put("schema_" + c + "_checked", cs.contains(field.name()) ? 1 : 0);
prop.putHTML("schema_" + c + "_key", field.name());
prop.putHTML("schema_" + c + "_solrfieldname",field.name().equalsIgnoreCase(field.getSolrFieldName()) ? "" : field.getSolrFieldName());
if (field.getComment() != null) prop.putHTML("schema_" + c + "_comment",field.getComment());
c++;
}
}
prop.put("schema", c);

Loading…
Cancel
Save