</permacrud>
</class>
- <class id="cza" controller="open-ils.cstore" oils_obj:fieldmapper="config::z3950_attr" oils_persist:tablename="config.z3950_attr" reporter:label="Z39.50 Attribute">
+ <class id="cza" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::z3950_attr" oils_persist:tablename="config.z3950_attr" reporter:label="Z39.50 Attribute">
<fields oils_persist:primary="id" oils_persist:sequence="config.z3950_attr_id_seq">
<field reporter:label="Z39.50 Attribute ID" name="id" reporter:datatype="id"/>
<field reporter:label="Z39.50 Source" name="source" reporter:datatype="link"/>
<links>
<link field="source" reltype="has_a" key="name" map="" class="czs"/>
</links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <create permission="ADMIN_Z3950_SOURCE" global_required="true"/>
+ <retrieve/>
+ <update permission="ADMIN_Z3950_SOURCE" global_required="true"/>
+ <delete permission="ADMIN_Z3950_SOURCE" global_required="true"/>
+ </actions>
+ </permacrud>
</class>
<class id="ateo" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="action_trigger::event_output" oils_persist:tablename="action_trigger.event_output" reporter:label="Event Output">
<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+[% source_code = ctx.page_args.0;
+ IF source_code %]
+
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+ <div>[% l('Z39.50 Attributes for [_1]', source_code) | html %]</div>
+ <div>
+ <button dojoType='dijit.form.Button' onClick='zaGrid.showCreateDialog()'>[% l('New') %]</button>
+ <button dojoType='dijit.form.Button' onClick='zaGrid.deleteSelected()'>[% l('Delete Selected') %]</button>
+ <button dojoType='dijit.form.Button' onClick='showAttrCloneDialog()'>[% l('Clone Attributes From Source') %]</button>
+ </div>
+ </div>
+ <div>
+ <button onClick="location.href = location.href.replace(/\/[^\/]+$/, '')">[% l('Return to Sources') %]</button>
+ </div>
+ <br/>
+
+ <table
+ id="zaGrid"
+ jsid="zaGrid"
+ dojoType="openils.widget.FlattenerGrid"
+ columnPersistKey='"conify.config.z3950_attr"'
+ autoHeight="true"
+ editOnEnter="true"
+ editStyle="pane"
+ showLoadFilter="true"
+ fmClass="'cza'"
+ defaultSort="['code']"
+ query="{'source': ['[% source_code %]']}">
+ <thead>
+ <tr>
+ <th field="source" fpath="source" ffilter="true"/>
+ <th field="name" fpath="name" ffilter="true"/>
+ <th field="label" fpath="label" ffilter="true"/>
+ <th field="code" fpath="code" ffilter="true"/>
+ <th field="format" fpath="format" ffilter="true"/>
+ <th field="truncation" fpath="truncation" ffilter="true"/>
+ </tr>
+ </thead>
+ </table>
+
+ <div jsId="attrCloneDialog" dojoType="dijit.Dialog">
+ <span>[% l('Select a source to clone') %]</span>
+ <span><div id='attr-clone-source'></div></span>
+ <span><button onClick='cloneFromSource()'>[% l('Apply') %]</button></span>
+ </div>
+
+[% ELSE %]
+
<div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
<div>Z39.50 Servers</div>
<div>
defaultCellWidth='"auto"'
fmClass='czs'
editOnEnter='true'>
+ <thead>
+ <th field='name' formatter='formatSourceName'/>
+ </thead>
</table>
-</div>
[% END %]
+</div>
+
+<script>var sourceCode = '[% source_code %]';</script>
+
+[% END %]
dojo.require('dojo.data.ItemFileReadStore');
dojo.require('dijit.form.NumberTextBox');
dojo.require('dijit.form.CheckBox');
+dojo.require('dijit.Dialog');
dojo.require('fieldmapper.OrgUtils');
dojo.require('openils.widget.OrgUnitFilteringSelect');
dojo.require('openils.widget.AutoGrid');
+dojo.require('openils.widget.FlattenerGrid');
+dojo.require('openils.widget.AutoFieldWidget');
+dojo.require('openils.User');
+dojo.require('openils.PermaCrud');
var zsList;
function buildZSGrid() {
- zsGrid.loadAll({order_by:{czs : 'name'}});
+
+ if (sourceCode) {
+
+ zaGrid.overrideWidgetArgs.source = {
+ widgetValue : sourceCode,
+ readOnly : true
+ };
+
+ } else {
+
+ zsGrid.loadAll({order_by:{czs : 'name'}});
+ }
+}
+
+function formatSourceName(val) {
+ return '<a href="' + location.href + '/' + escape(val) + '">' + val + '</a>';
+}
+
+var cloneSourceSelector;
+function showAttrCloneDialog() {
+ attrCloneDialog.show();
+ if (!cloneSourceSelector) {
+ cloneSourceSelector = new openils.widget.AutoFieldWidget({
+ fmClass : 'czs',
+ fmField : 'name',
+ selfReference : true,
+ parentNode : 'attr-clone-source'
+ });
+ cloneSourceSelector.build();
+ }
+}
+
+function cloneFromSource() {
+ var pcrud = new openils.PermaCrud({authtoken : openils.User.authtoken});
+ var remoteAttrs = pcrud.search('cza', {source : cloneSourceSelector.widget.attr('value')});
+ var myAttrs = pcrud.search('cza', {source : sourceCode});
+ var newAttrs = [];
+
+ dojo.forEach(remoteAttrs,
+ function(rattr) {
+
+ // if this source already has an attribute with the same name, don't clobber it
+ if (myAttrs.filter(function(a) { return (a.name() == rattr.name()) })[0])
+ return;
+
+ var newAttr = rattr.clone();
+ newAttr.id(null);
+ newAttr.isnew(true);
+ newAttr.source(sourceCode);
+ newAttrs.push(newAttr);
+ }
+ );
+
+ if (newAttrs.length) {
+ pcrud.create(newAttrs,
+ {oncomplete : function() { zaGrid.refresh() }});
+ }
+
+ attrCloneDialog.hide();
}
openils.Util.addOnLoad(buildZSGrid);
--- /dev/null
+Z39.50 Source Attributes Management Interface
+---------------------------------------------
+
+There is a new interface for managing Z39.50 attributes on a Z39.50
+source. The interface is linked from each source name in the Z39.50
+Source administrative interface.
+
+Cloning
+~~~~~~~
+
+In addition to attribute creation, deletion, and editing, it's also
+possible to clone a set of attributes from one source into another.
+When cloning, any attributes present in the cloned source that are
+not present in the destination source are copied into the destination
+source.
+