Skip to content

Commit

Permalink
Frontend support for TS settings & customize LemmaSugg URL (re #48)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Bollmann committed Apr 5, 2017
1 parent 533699f commit b72e040
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/db/migration/5-to-6.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@

LOCK TABLES `tagset` WRITE;
ALTER TABLE `tagset` ADD COLUMN `settings` text DEFAULT NULL;

-- preserve old default behaviour
UPDATE `tagset` SET `settings`='{"url_with_id": "http://www.woerterbuchnetz.de/DWB?lemid={value}", "url_with_lemma": "http://www.woerterbuchnetz.de/DWB?lemma={value}"}' WHERE `class`="lemma_sugg";

UNLOCK TABLES;
23 changes: 15 additions & 8 deletions src/gui/js/tagsets/LemmaSugg.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var LemmaSuggTagset = new Class({
eventString: 'click:relay(div.editTableLemmaLink)',
searchable: false,
exportable: false,
baseURL: "http://www.woerterbuchnetz.de/DWB",
windowTarget: "coraExternalLemmaLink",

/* Constructor: Tagset
Expand Down Expand Up @@ -98,14 +97,22 @@ var LemmaSuggTagset = new Class({
Opens a link to an external website.
*/
openExternalLemmaLink: function(value) {
var split, targetURL = this.baseURL;
if (typeof(value) !== "undefined" && value !== null) {
var split, targetURL = null;
if (this.settings && typeof(value) !== "undefined" && value !== null) {
split = this._acSplitExternalId(value);
if(split[1].length > 0)
targetURL = targetURL + "?lemid=" + split[1];
else
targetURL = targetURL + "?lemma=" + split[0];
if(split[1].length > 0) {
if(this.settings['url_with_id'])
targetURL = this.settings['url_with_id'].substitute({value: split[1]});
}
else {
if(this.settings['url_with_lemma'])
targetURL = this.settings['url_with_lemma'].substitute({value: split[0]});
}
}
if(targetURL) {
window.open(targetURL, this.windowTarget);
} else {
gui.showNotice('error', _("Banner.tagsetLemmaSuggNoURL"));
}
window.open(targetURL, this.windowTarget);
}
});
4 changes: 4 additions & 0 deletions src/gui/js/tagsets/Tagset.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var Tagset = new Class({
exportable: true, /**< can user export this tagset in CSV format? */
split_class: false, /**< is this tagset displayed as two? */
value_key: '', /**< defaults to "anno_" + class */
settings: null, /**< tagset-specific settings as defined in the database */

tags: [],
processed: false,
Expand Down Expand Up @@ -100,6 +101,9 @@ var Tagset = new Class({
this.class = data.class;
this.value_key = "anno_" + this.class;
}
if(typeof(data.settings) !== "undefined" && data.settings) {
this.settings = JSON.parse(data.settings);
}
},

/* Function: setShowInputErrors
Expand Down
1 change: 1 addition & 0 deletions src/locale/Locale.de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
"taggerDeleted": "Tagger gel\u00f6scht.",
"taggerOptionsUpdated": "Tagger-Optionen ge\u00e4ndert.",
"tagsetsChanged": "Tagset-Verkn\u00fcpfungen ge\u00e4ndert.",
"tagsetLemmaSuggNoURL": "Keine URL f\u00fcr den Lemma-Link eingestellt!",
"transcriptionEmpty": "Transkription darf nicht leer sein!",
"userAdded": "Benutzer hinzugef\u00fcgt.",
"userDeleted": "Benutzer gel\u00f6scht.",
Expand Down
1 change: 1 addition & 0 deletions src/locale/Locale.en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
"taggerDeleted": "Tagger successfully deleted.",
"taggerOptionsUpdated": "Tagger options updated successfully.",
"tagsetsChanged": "Applied tagset settings.",
"tagsetLemmaSuggNoURL": "No URL defined for external lemma link!",
"transcriptionEmpty": "Please enter a transcription!",
"userAdded": "User added.",
"userDeleted": "User successfully deleted.",
Expand Down

0 comments on commit b72e040

Please sign in to comment.