App-Dochazka-WWW
view release on metacpan or search on metacpan
share/js/dochazka-www/sched-history-lib.js view on Meta::CPAN
stack,
start
) {
var actionSchedHistory = function () {
var rest = {
"method": 'GET',
"path": 'schedule/history/nick/' + currentUser('obj').nick
},
// success callback
sc = function (st) {
if (st.code === 'DISPATCH_RECORDS_FOUND') {
console.log("Payload is", st.payload);
var history = st.payload.history.map(
function (row) {
return {
"shid": row.shid,
"sid": row.sid,
"effective": datetime.readableDate(row.effective),
"scode": row.scode
};
}
);
stack.push('schedHistoryDrowselect', {
'pos': 0,
'set': history
}, { "xtarget": "myProfileAction" });
}
},
fc = function (st) {
if (st.payload.code === "404") {
stack.push('schedHistoryDrowselect', {
'pos': 0,
'set': []
}, { "xtarget": "myProfileAction" });
}
};
ajax(rest, sc, fc);
},
schedHistorySaveAction = function () {
var rest = {
"method": 'POST',
"path": 'schedule/history/nick/' + currentUser('obj').nick,
"body": {
"effective": $("#pHeffective").val(),
"sid": $("#sDid").val(),
"scode": $("#sDcode").val()
}
},
// success callback
sc = function (st) {
if (st.code === 'DOCHAZKA_CUD_OK') {
console.log("Payload is", st.payload);
stack.unwindToTarget("actionSchedHistory");
}
},
fc = function (st) {
lib.displayError(st.payload.message);
if (st.payload.code === '404') {
// go back to miniMenu listener
$('input[name="sel"]').val('').focus();
}
};
ajax(rest, sc, fc);
// start.drowselectListen();
},
schedHistoryDeleteAction = function () {
var shid,
set = lib.drowselectState.set,
pos = lib.drowselectState.pos,
rest = {
"method": 'DELETE',
"path": 'schedule/history/shid/'
},
// success callback
sc = function (st) {
if (st.code === 'DOCHAZKA_CUD_OK') {
console.log("Payload is", st.payload);
stack.unwindToTarget("actionSchedHistory");
}
},
fc = function (st) {
lib.displayError(st.payload.message);
$('input[name="sel"]').val('').focus();
};
if (set === null || set === undefined || set.length === 0) {
lib.displayError("Nothing to do");
$('input[name="sel"]').val('').focus();
// start.drowselectListen();
}
shid = set[pos].shid;
console.log("Going to delete SHID " + shid);
rest.path += shid;
ajax(rest, sc, fc);
// start.drowselectListen();
},
schedHistoryAddRecordAction = function () {
var cu = currentUser('obj');
console.log("Entering schedHistoryAddRecordAction, nick is " + cu.nick);
stack.push('schedHistoryAddRecord', {
'nick': cu.nick
});
}
;
return {
"actionSchedHistory": actionSchedHistory,
"schedHistorySaveAction": schedHistorySaveAction,
"schedHistoryDeleteAction": schedHistoryDeleteAction,
"schedHistoryAddRecordAction": schedHistoryAddRecordAction,
};
});
( run in 1.588 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )