<div id="org-selector"></div>
</td>
<td class="note">
- [% l("This will only be used if your search doesn't contain a hand-entered filter such as site(BR1)") %]
+ [% l("This will only be used if your search doesn't contain an explicit filter such as site(BR1)") %]
</td>
</tr>
constant load time regardless of dataset size. -->
<select id="saved-searches" multiple="true" size="6"></select>
</td>
- <td class="note">[% l("Optionally select one or more to combine with 'Search' field above.") %]
+ <td class="note">
+ <p>[% l("Optionally select one or more to combine with 'Search' field above.") %]</p>
+ <p class="hidden" id="clone-saved-search-warning">
+ [% l("NOTE: When cloning sessions, any saved searches used in the original session will already be mentioned in the 'Search' field above. You should not need to select them again here.") %]
+ </p>
</td>
</tr>
<tr>
<th>
- [% l('Tags and subfields possibly containing URLs:') %]
+ [% l('Tags and subfields to search for URLs:') %]
</th>
<td>
<div id="uv-tags-and-subfields">
</div>
<div class="tag-and-subfield-add-another">
[% l("Tag") %]
- <input type="text" size="4" maxlength="3" />
+ <input type="text" size="3" maxlength="3" />
[% l("Subfield(s)") %]
- <input type="text" size="15" />
+ <input type="text" size="8" />
<a href="javascript:module.tag_and_subfields.add();">[% l('Add') %]</a>
</div>
</td>
dojo.require("dojox.jsonPath");
dojo.require("fieldmapper.OrgUtils");
dojo.require("openils.Util");
+ dojo.require("openils.CGI");
dojo.require("openils.PermaCrud");
dojo.require("openils.widget.FilteringTreeSelect");
dojo.require("openils.URLVerify.Verify");
* fewer moving parts that can go haywire anyway.
*/
module._populate_saved_searches = function(node) {
- var pcrud = new openils.PermaCrud();
- var list = pcrud.retrieveAll("asq", {"order_by": {"asq": "label"}});
+ var list = module.pcrud.retrieveAll(
+ "asq", {"order_by": {"asq": "label"}}
+ );
dojo.forEach(
list, function(o) {
);
}
);
-
- pcrud.disconnect();
};
/* set up an all-org-units-in-the-tree selector */
module.org_selector = widget;
};
+ /* Can only be called by setup() */
+ module._clone = function(id) {
+ module.progress_dialog.attr("title", localeStrings.CLONING);
+ var old_session = module.pcrud.retrieve(
+ "uvs", id, {"flesh": 1, "flesh_fields": {"uvs": ["selectors"]}}
+ );
+
+ /* Set name to "Copy of [old name]" */
+ uv_session_name.attr(
+ "value", dojo.string.substitute(
+ localeStrings.CLONE_SESSION_NAME, [old_session.name()]
+ )
+ );
+
+ /* Set search field. */
+ uv_search.attr("value", old_session.search());
+
+ /* Explain to user why we don't affect the saved searches picker. */
+ if (old_session.search().match(/saved_query/))
+ openils.Util.show("clone-saved-search-warning");
+
+ /* Add related xpaths (URL selectors) to TagAndSubfieldsMgr. */
+ module.tag_and_subfields.add_xpaths(old_session.selectors());
+ };
+
module.setup = function(saved_search_id, org_selector_id, progress_dialog) {
+ module.pcrud = new openils.PermaCrud(); /* only used for setup */
+
module.progress_dialog = progress_dialog;
module.progress_dialog.attr("title", localeStrings.INTERFACE_SETUP);
module._populate_saved_searches(dojo.byId(saved_search_id));
module._prepare_org_selector(dojo.byId(org_selector_id));
+ var cgi = new openils.CGI();
+ if (cgi.param("clone"))
+ module._clone(cgi.param("clone"));
+
+ module.pcrud.disconnect();
+
module.progress_dialog.hide();
};
"innerHTML": "[X]" /* XXX i18n */
}, div, "last"
);
+ };
+
+ this.add_xpaths = function(xpaths) {
+ if (!dojo.isArray(xpaths)) {
+ console.info("No xpaths to add");
+ return;
+ }
- this.counter++;
+ dojo.forEach(
+ xpaths, dojo.hitch(this, function(xpath) {
+ var newid = "t-and-s-row-" + String(this.counter++);
+ var div = dojo.create(
+ "div", {
+ "id": newid,
+ "innerHTML": localeStrings.XPATH +
+ " <span class='t-and-s-xpath'>" +
+ xpath.xpath() + "</span>"
+ }, this.container_id, "last"
+ );
+ dojo.create(
+ "a", {
+ "href": "javascript:void(0);",
+ "onclick": function() {
+ var me = dojo.byId(newid);
+ me.parentNode.removeChild(me);
+ },
+ "innerHTML": "[X]" /* XXX i18n */
+ }, div, "last"
+ );
+ })
+ );
};
/* return a boolean indicating whether or not we have any rows */
'[id^="t-and-s-row-"]', dojo.byId(this.container_id)
).forEach(
function(row) {
- var tag = dojo.query(".t-and-s-tag", row)[0].innerHTML;
- var subfield = dojo.query(".t-and-s-subfields", row)[0].innerHTML;
-
- var existing;
- if ((existing = uniquely_grouped[tag])) { /* sic, assignment */
- existing = openils.Util.uniqueElements(
- (existing + subfield).split("")
- ).sort().join("");
+ var holds_xpath = dojo.query(".t-and-s-xpath", row);
+ if (holds_xpath.length) {
+ uniquely_grouped.xpath = uniquely_grouped.xpath || [];
+ uniquely_grouped.xpath.push(holds_xpath[0].innerHTML);
} else {
- uniquely_grouped[tag] = subfield;
+ var tag = dojo.query(".t-and-s-tag", row)[0].innerHTML;
+ var subfield =
+ dojo.query(".t-and-s-subfields", row)[0].innerHTML;
+
+ var existing;
+ if ((existing = uniquely_grouped[tag])) { // assignment
+ existing = openils.Util.uniqueElements(
+ (existing + subfield).split("")
+ ).sort().join("");
+ } else {
+ uniquely_grouped[tag] = subfield;
+ }
}
}
);
var uvus_list = [];
+ /* Handle things that are already in XPath form first (these
+ * come from cloning link checker sessions. */
+ if (uniquely_grouped.xpath) {
+ dojo.forEach(
+ uniquely_grouped.xpath,
+ function(xpath) {
+ var obj = new uvus();
+
+ obj.session(session_id);
+ obj.xpath(xpath);
+ uvus_list.push(obj);
+ }
+ );
+ delete uniquely_grouped.xpath;
+ }
+
+ /* Now handle anything entered by hand. */
for (var tag in uniquely_grouped) {
var obj = new uvus();
obj.session(session_id);
- /* XXX TODO handle control fields (no subfields) */
+ /* XXX TODO Handle control fields (No subfields. but would
+ * control fields ever contain URLs? Don't know.) */
obj.xpath(
"//*[@tag='" + tag + "']/*[" +
uniquely_grouped[tag].split("").map(