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>Active</td>
<td>Attribute</td> <td>Attribute</td>
<td>Custom Solr Field Name</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> </tr>
#{schema}# #{schema}#
<tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#"> <tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#">

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

Loading…
Cancel
Save