View | Details | Raw Unified | Return to bug 34035
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/js/tags.js (-57 / +56 lines)
Lines 6-70 if (typeof KOHA == "undefined" || !KOHA) { Link Here
6
* A namespace for Tags related functions.
6
* A namespace for Tags related functions.
7
7
8
$.ajaxSetup({
8
$.ajaxSetup({
9
	url: "/cgi-bin/koha/opac-tags.pl",
9
    url: "/cgi-bin/koha/opac-tags.pl",
10
	type: "POST",
10
    type: "POST",
11
	dataType: "script"
11
    dataType: "script"
12
});
12
});
13
*/
13
*/
14
KOHA.Tags = {
14
KOHA.Tags = {
15
    add_tag_button: function(bibnum, tag){
15
    add_tag_button: function(bibnum, tag){
16
        var mynewtag = "newtag" + bibnum;
16
        var mynewtag = "newtag" + bibnum;
17
		var mytagid = "#" + mynewtag;
17
        var mytagid = "#" + mynewtag;
18
        var mydata = {};
18
        var mydata = {};
19
        mydata[mynewtag] = tag;
19
        mydata[mynewtag] = tag;
20
		var response;	// AJAX from server will assign value to response.
20
        var response;	// AJAX from server will assign value to response.
21
		$.post(
21
        $.post(
22
			"/cgi-bin/koha/opac-tags.pl",
22
            "/cgi-bin/koha/opac-tags.pl",
23
			mydata,
23
            mydata,
24
			function(data){
24
            function(data){
25
				// alert("AJAX Response: " + data);
25
                // alert("AJAX Response: " + data);
26
				eval(data);
26
                eval(data);
27
				// alert("counts: " + response["added"] + response["deleted"] + response["errors"]);
27
                // alert("counts: " + response["added"] + response["deleted"] + response["errors"]);
28
				KOHA.Tags.set_tag_status(
28
                KOHA.Tags.set_tag_status(
29
					mytagid + "_status",
29
                    mytagid + "_status",
30
					KOHA.Tags.common_status(response["added"], response["deleted"], response["errors"])
30
                    KOHA.Tags.common_status(response["added"], response["deleted"], response["errors"])
31
				);
31
                );
32
				if (response.alerts) {
32
                if (response.alerts) {
33
					alert(response.alerts.join("\n\n"));
33
                    alert(response.alerts.join("\n\n"));
34
				}
34
                }
35
			},
35
            },
36
			'script'
36
            'script'
37
		);
37
        );
38
		return false;
38
        return false;
39
	},
39
    },
40
	common_status : function(addcount, delcount, errcount) {
40
    common_status : function(addcount, delcount, errcount) {
41
	    var cstat = "";
41
        var cstat = "";
42
	    if (addcount && addcount > 0) {cstat += MSG_TAGS_ADDED + addcount + ".  " ;}
42
        if (addcount && addcount > 0) {cstat += MSG_TAGS_ADDED + addcount + ".  " ;}
43
	    if (delcount && delcount > 0) {cstat += MSG_TAGS_DELETED + delcount + ".  " ;}
43
        if (delcount && delcount > 0) {cstat += MSG_TAGS_DELETED + delcount + ".  " ;}
44
	    if (errcount && errcount > 0) {cstat += MSG_TAGS_ERRORS + errcount + ". " ;}
44
        if (errcount && errcount > 0) {cstat += MSG_TAGS_ERRORS + errcount + ". " ;}
45
	    return cstat;
45
        return cstat;
46
	},
46
    },
47
	set_tag_status : function(tagid, newstatus) {
47
    set_tag_status : function(tagid, newstatus) {
48
		$(tagid).html(newstatus);
48
        $(tagid).html(newstatus);
49
        $(tagid).show();
49
        $(tagid).show();
50
	},
50
    },
51
	append_tag_status : function(tagid, newstatus) {
51
    append_tag_status : function(tagid, newstatus) {
52
		$(tagid).append(newstatus);
52
        $(tagid).append(newstatus);
53
        $(tagid).show();
53
        $(tagid).show();
54
	},
54
    },
55
    clear_all_tag_status : function() {
55
    clear_all_tag_status : function() {
56
        $(".tagstatus").empty().hide();
56
        $(".tagstatus").empty().hide();
57
    },
57
    },
58
58
59
	tag_message: {
59
    tag_message: {
60
	tagsdisabled : function(arg) {return (MSG_TAGS_DISABLED);},
60
    tagsdisabled : function(arg) {return (MSG_TAGS_DISABLED);},
61
	scrubbed_all_bad : function(arg) {return (MSG_TAG_ALL_BAD);},
61
    scrubbed_all_bad : function(arg) {return (MSG_TAG_ALL_BAD);},
62
	badparam : function(arg) {return (MSG_ILLEGAL_PARAMETER+" "+arg);},
62
    badparam : function(arg) {return (MSG_ILLEGAL_PARAMETER+" "+arg);},
63
	scrubbed : function(arg) {return (MSG_TAG_SCRUBBED+" "+arg);},
63
    scrubbed : function(arg) {return (MSG_TAG_SCRUBBED+" "+arg);},
64
    failed_add_tag : function(arg) {return (MSG_ADD_TAG_FAILED+ " '"+arg+"'. \n"+MSG_ADD_TAG_FAILED_NOTE);},
64
    failed_add_tag : function(arg) {return (MSG_ADD_TAG_FAILED+ " '"+arg+"'. \n"+MSG_ADD_TAG_FAILED_NOTE);},
65
    failed_delete  : function(arg) {return (MSG_DELETE_TAG_FAILED+ " '"+arg+"'. \n"+MSG_DELETE_TAG_FAILED_NOTE);},
65
    failed_delete  : function(arg) {return (MSG_DELETE_TAG_FAILED+ " '"+arg+"'. \n"+MSG_DELETE_TAG_FAILED_NOTE);},
66
	login : function(arg) {return (MSG_LOGIN_REQUIRED);}
66
    login : function(arg) {return (MSG_LOGIN_REQUIRED);}
67
	},
67
    },
68
68
69
    // Used to tag multiple items at once.  The main difference
69
    // Used to tag multiple items at once.  The main difference
70
    // is that status is displayed on a per item basis.
70
    // is that status is displayed on a per item basis.
Lines 74-85 KOHA.Tags = { Link Here
74
            var mynewtag = "newtag" + bibarray[i];
74
            var mynewtag = "newtag" + bibarray[i];
75
            mydata[mynewtag] = tag;
75
            mydata[mynewtag] = tag;
76
        }
76
        }
77
		var response;	// AJAX from server will assign value to response.
77
        var response;	// AJAX from server will assign value to response.
78
		$.post(
78
        $.post(
79
			"/cgi-bin/koha/opac-tags.pl",
79
            "/cgi-bin/koha/opac-tags.pl",
80
			mydata,
80
            mydata,
81
			function(data){
81
            function(data){
82
				eval(data);
82
                eval(data);
83
                KOHA.Tags.clear_all_tag_status();
83
                KOHA.Tags.clear_all_tag_status();
84
                var bibErrors = false;
84
                var bibErrors = false;
85
85
Lines 94-100 KOHA.Tags = { Link Here
94
                        var added = response[bib]["added"];
94
                        var added = response[bib]["added"];
95
                        if (added > 0) {
95
                        if (added > 0) {
96
                            status = MSG_TAGS_ADDED + added + ".  ";
96
                            status = MSG_TAGS_ADDED + added + ".  ";
97
				        KOHA.Tags.set_tag_status(mytagid + "_status", status);
97
                        KOHA.Tags.set_tag_status(mytagid + "_status", status);
98
                        }
98
                        }
99
99
100
                        // Show a link that opens an error dialog, if necessary.
100
                        // Show a link that opens an error dialog, if necessary.
Lines 105-111 KOHA.Tags = { Link Here
105
                            var errstat = "<a id=\"" + errid + "\" class=\"tagerror\" href=\"#\">";
105
                            var errstat = "<a id=\"" + errid + "\" class=\"tagerror\" href=\"#\">";
106
                            errstat += MSG_TAGS_ERRORS + errors.length + ". ";
106
                            errstat += MSG_TAGS_ERRORS + errors.length + ". ";
107
                            errstat += "</a>";
107
                            errstat += "</a>";
108
					    KOHA.Tags.append_tag_status(mytagid + "_status", errstat);
108
                        KOHA.Tags.append_tag_status(mytagid + "_status", errstat);
109
                            var errmsg = "";
109
                            var errmsg = "";
110
                            for (var e = 0; e < errors.length; e++){
110
                            for (var e = 0; e < errors.length; e++){
111
                                if (e) {
111
                                if (e) {
Lines 137-145 KOHA.Tags = { Link Here
137
                    }
137
                    }
138
                    alert(msg);
138
                    alert(msg);
139
                }
139
                }
140
			},
140
            },
141
			'script'
141
            'script'
142
		);
142
        );
143
		return false;
143
        return false;
144
    }
144
    }
145
};
145
};
146
- 

Return to bug 34035