nightly commit
This commit is contained in:
@@ -54,6 +54,8 @@ class CalendarDatabase(object):
|
||||
|
||||
if config.CustomConfig['database-type'] == 'sqlite':
|
||||
self.db = sqlite3.connect(config.CustomConfig['database-config']['url'], check_same_thread = False)
|
||||
self.db.execute('PRAGMA encoding = "UTF-8";')
|
||||
self.db.execute('PRAGMA foreign_keys = ON;')
|
||||
elif config.CustomConfig['database-type'] == 'mysql':
|
||||
raise Exception('Not implemented database')
|
||||
else:
|
||||
@@ -323,7 +325,7 @@ class CalendarDatabase(object):
|
||||
@SafeDatabaseOperation
|
||||
def collection_getFullOwn(self, token):
|
||||
username = self.tokenOper_get_username(token)
|
||||
self.cursor.execute('SELECT * FROM collection WHERE [ccn_user] = ?;', (username, ))
|
||||
self.cursor.execute('SELECT [ccn_uuid], [ccn_name], [ccn_lastChange] FROM collection WHERE [ccn_user] = ?;', (username, ))
|
||||
return self.cursor.fetchall()
|
||||
|
||||
@SafeDatabaseOperation
|
||||
@@ -335,7 +337,7 @@ class CalendarDatabase(object):
|
||||
@SafeDatabaseOperation
|
||||
def collection_getDetailOwn(self, token, uuid):
|
||||
username = self.tokenOper_get_username(token)
|
||||
self.cursor.execute('SELECT * FROM collection WHERE [ccn_user] = ? AND [ccn_uuid] = ?;', (username, uuid))
|
||||
self.cursor.execute('SELECT [ccn_uuid], [ccn_name], [ccn_lastChange] FROM collection WHERE [ccn_user] = ? AND [ccn_uuid] = ?;', (username, uuid))
|
||||
return self.cursor.fetchone()
|
||||
|
||||
@SafeDatabaseOperation
|
||||
@@ -352,7 +354,7 @@ class CalendarDatabase(object):
|
||||
self.tokenOper_check_valid(token)
|
||||
|
||||
lastupdate = utils.GenerateUUID()
|
||||
self.cursor.execute('UPDATE collection SET [ccn_name] = ? [ccn_lastChange] = ? WHERE [ccn_uuid] = ?, [ccn_lastChange] = ?;', (
|
||||
self.cursor.execute('UPDATE collection SET [ccn_name] = ?, [ccn_lastChange] = ? WHERE [ccn_uuid] = ? AND [ccn_lastChange] = ?;', (
|
||||
newname,
|
||||
lastupdate,
|
||||
uuid,
|
||||
@@ -366,7 +368,7 @@ class CalendarDatabase(object):
|
||||
def collection_deleteOwn(self, token, uuid, lastChange):
|
||||
self.tokenOper_check_valid(token)
|
||||
|
||||
self.cursor.execute('DELETE FROM collection WHERE [ccn_uuid] = ?, [ccn_lastChange] = ?;', (
|
||||
self.cursor.execute('DELETE FROM collection WHERE [ccn_uuid] = ? AND [ccn_lastChange] = ?;', (
|
||||
uuid,
|
||||
lastChange
|
||||
))
|
||||
@@ -385,7 +387,7 @@ class CalendarDatabase(object):
|
||||
self.tokenOper_check_valid(token)
|
||||
|
||||
lastupdate = utils.GenerateUUID()
|
||||
self.cursor.execute('UPDATE share SET [ccn_lastChange] = ? WHERE [ccn_uuid] = ? AND [ccn_lastChange] = ?;', (lastupdate, uuid, lastChange))
|
||||
self.cursor.execute('UPDATE collection SET [ccn_lastChange] = ?, WHERE [ccn_uuid] = ? AND [ccn_lastChange] = ?;', (lastupdate, uuid, lastChange))
|
||||
if self.cursor.rowcount != 1:
|
||||
raise Exception('Fail to delete due to no matched rows or too much rows.')
|
||||
|
||||
@@ -400,11 +402,11 @@ class CalendarDatabase(object):
|
||||
self.tokenOper_check_valid(token)
|
||||
|
||||
lastupdate = utils.GenerateUUID()
|
||||
self.cursor.execute('UPDATE share SET [ccn_lastChange] = ? WHERE [ccn_uuid] = ? AND [ccn_lastChange] = ?;', (lastupdate, uuid, lastChange))
|
||||
self.cursor.execute('UPDATE collection SET [ccn_lastChange] = ? WHERE [ccn_uuid] = ? AND [ccn_lastChange] = ?;', (lastupdate, uuid, lastChange))
|
||||
if self.cursor.rowcount != 1:
|
||||
raise Exception('Fail to delete due to no matched rows or too much rows.')
|
||||
|
||||
self.cursor.execute('SELECT * FROM share WHERE [ccn_uuid] = ? AND [ccn_lastChange] = ?;', (uuid, target))
|
||||
self.cursor.execute('SELECT * FROM share WHERE [ccn_uuid] = ? AND [ccn_target] = ?;', (uuid, target))
|
||||
if len(self.cursor.fetchall()) != 0:
|
||||
raise Exception('Fail to insert duplicated item.')
|
||||
self.cursor.execute('INSERT INTO share VALUES (?, ?);', (uuid, target))
|
||||
@@ -414,7 +416,7 @@ class CalendarDatabase(object):
|
||||
@SafeDatabaseOperation
|
||||
def collection_getShared(self, token):
|
||||
username = self.tokenOper_get_username(token)
|
||||
self.cursor.execute('SELECT collection.ccn_uuid, collection.name, collection.user \
|
||||
self.cursor.execute('SELECT collection.ccn_uuid, collection.ccn_name, collection.ccn_user \
|
||||
FROM share INNER JOIN collection \
|
||||
ON share.ccn_uuid = collection.ccn_uuid \
|
||||
WHERE share.ccn_target = ?;', (username, ))
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
PRAGMA encoding = "UTF-8";
|
||||
PRAGMA foreign_keys = ON;
|
||||
|
||||
CREATE TABLE user(
|
||||
[ccn_name] TEXT NOT NULL,
|
||||
[ccn_password] TEXT NOT NULL,
|
||||
|
||||
@@ -46,7 +46,7 @@ ccn-calendar-week-friday=Friday
|
||||
ccn-calendar-week-saturday=Saturday
|
||||
ccn-calendar-week-sunday=Sunday
|
||||
ccn-calendar-shared-list=Shared
|
||||
ccn-calendar-sharing-ownedList=Owned
|
||||
ccn-calendar-ownedList=Owned
|
||||
ccn-calendar-sharing-sharingTargetList=Sharing target
|
||||
ccn-calendar-sharing-sharingTargetEditing=Editing:
|
||||
ccn-calendar-sharedItem-sharedBy=Shared by:
|
||||
|
||||
@@ -46,7 +46,7 @@ ccn-calendar-week-friday=星期五
|
||||
ccn-calendar-week-saturday=星期六
|
||||
ccn-calendar-week-sunday=星期日
|
||||
ccn-calendar-shared-list=被共享的集合
|
||||
ccn-calendar-sharing-ownedList=我的集合
|
||||
ccn-calendar-ownedList=我的集合
|
||||
ccn-calendar-sharing-sharingTargetList=分享目标
|
||||
ccn-calendar-sharing-sharingTargetEditing=正在编辑集合:
|
||||
ccn-calendar-sharedItem-sharedBy=共享人:
|
||||
|
||||
@@ -334,7 +334,7 @@ function ccn_api_collection_addSharing(_uuid, _target, _lastChange) {
|
||||
|
||||
function ccn_api_collection_getShared() {
|
||||
return ccn_api_dataTemplate(
|
||||
'/api/collection/addSharing',
|
||||
'/api/collection/getShared',
|
||||
{
|
||||
token: GetApiToken()
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// 3 used cache list
|
||||
var ccn_calendar_sharingListCache = [];
|
||||
var ccn_calendar_sharingTargetListCache = [];
|
||||
var ccn_calendar_sharedListCache = [];
|
||||
var ccn_calendar_owned_listCache = [];
|
||||
var ccn_calendar_sharing_listCache = [];
|
||||
var ccn_calendar_shared_listCache = [];
|
||||
|
||||
// current editing sharing collection
|
||||
var ccn_calendar_editingSharing = undefined; // the uuid of owned collection
|
||||
var ccn_calendar_sharing_editingOwned = undefined; // the uuid of owned collection
|
||||
|
||||
// 2 list which will store sharing and shared collection's display mode.
|
||||
// key is uuid, value is bool
|
||||
@@ -45,12 +45,16 @@ $(document).ready(function() {
|
||||
ccn_i18n_LoadLanguage();
|
||||
ccn_i18n_ApplyLanguage();
|
||||
|
||||
//refresh once
|
||||
ccn_calendar_shared_Refresh();
|
||||
ccn_calendar_owned_Refresh();
|
||||
|
||||
// bind event
|
||||
$('#ccn-calendar-shared-btnRefresh').click(ccn_calendar_shared_Refresh);
|
||||
$('#ccn-calendar-sharing-btnAdd').click(ccn_calendar_sharingList_Add);
|
||||
$('#ccn-calendar-owned-btnAdd').click(ccn_calendar_owned_Add);
|
||||
$('#ccn-calendar-own-btnRefresh').click(ccn_calendar_owned_Refresh);
|
||||
$('#ccn-calendar-sharing-btnAdd').click(ccn_calendar_sharing_Add);
|
||||
$('#ccn-calendar-sharing-btnRefresh').click(ccn_calendar_sharing_Refresh);
|
||||
$('#ccn-calendar-sharingTarget-btnAdd').click(ccn_calendar_sharingTargetList_Add);
|
||||
$('#ccn-calendar-sharingTarget-btnRefresh').click(ccn_calendar_sharingTarget_Refresh);
|
||||
});
|
||||
|
||||
// ================== calendar
|
||||
@@ -61,142 +65,156 @@ function ccn_calendar_LoadCalendarBody() {
|
||||
|
||||
// ================== collection
|
||||
|
||||
function ccn_calendar_sharing_Refresh() {
|
||||
ccn_calendar_sharingListCache = new Array();
|
||||
function ccn_calendar_owned_Refresh() {
|
||||
ccn_calendar_owned_listCache = new Array();
|
||||
ccn_calendar_sharing_displayCache = new Array();
|
||||
|
||||
var result = ccn_api_collection_getFullOwn();
|
||||
if(typeof(result) != 'undefined') {
|
||||
for(var index in result) {
|
||||
ccn_calendar_sharingListCache[result[index][0]] = result[index];
|
||||
ccn_calendar_owned_listCache[result[index][0]] = result[index];
|
||||
ccn_calendar_sharing_displayCache[result[index][0]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// render
|
||||
$('#ccn-calendar-sharingList').empty();
|
||||
|
||||
var listDOM = $('#ccn-calendar-sharingList');
|
||||
for(var index in ccn_calendar_sharingListCache) {
|
||||
ccn_admin_userList_RenderItem(
|
||||
ccn_calendar_sharingListCache[index],
|
||||
var listDOM = $('#ccn-calendar-ownedList');
|
||||
listDOM.empty();
|
||||
for(var index in ccn_calendar_owned_listCache) {
|
||||
ccn_calendar_owned_RenderItem(
|
||||
ccn_calendar_owned_listCache[index],
|
||||
listDOM
|
||||
)
|
||||
}
|
||||
|
||||
// also, order sharing list clean
|
||||
ccn_calendar_sharing_editingOwned = undefined;
|
||||
ccn_calendar_sharing_Refresh();
|
||||
}
|
||||
|
||||
function ccn_calendar_sharing_RenderItem(item, listDOM) {
|
||||
function ccn_calendar_owned_RenderItem(item, listDOM) {
|
||||
var renderdata = {
|
||||
uuid: item[0],
|
||||
name: item[1]
|
||||
}
|
||||
|
||||
// render
|
||||
listDOM.append(ccn_template_sharingItem.render(renderdata));
|
||||
listDOM.append(ccn_template_ownedItem.render(renderdata));
|
||||
|
||||
// set mode
|
||||
var uuid = renderdata.uuid;
|
||||
ccn_calendar_sharing_ChangeDisplayMode(uuid, true, false);
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, true, false);
|
||||
|
||||
// bind event
|
||||
$('#ccn-calendar-sharingItem-btnEdit-' + uuid).click(ccn_calendar_sharingList_ItemEdit);
|
||||
$('#ccn-calendar-sharingItem-btnDelete-' + uuid).click(ccn_calendar_sharingList_ItemDelete);
|
||||
$('#ccn-calendar-sharingItem-btnShare-' + uuid).click(ccn_calendar_sharingList_ItemShare);
|
||||
$('#ccn-calendar-sharingItem-btnHide-' + uuid).click(ccn_calendar_sharingList_ItemSwitchDisplay);
|
||||
$('#ccn-calendar-sharingItem-btnShow-' + uuid).click(ccn_calendar_sharingList_ItemSwitchDisplay);
|
||||
$('#ccn-calendar-sharingItem-btnUpdate-' + uuid).click(ccn_calendar_sharingList_ItemUpdate);
|
||||
$('#ccn-calendar-sharingItem-btnCancelUpdate-' + uuid).click(ccn_calendar_sharingList_ItemCancelUpdate);
|
||||
$('#ccn-calendar-ownedItem-btnEdit-' + uuid).click(ccn_calendar_owned_ItemEdit);
|
||||
$('#ccn-calendar-ownedItem-btnDelete-' + uuid).click(ccn_calendar_owned_ItemDelete);
|
||||
$('#ccn-calendar-ownedItem-btnShare-' + uuid).click(ccn_calendar_owned_ItemShare);
|
||||
$('#ccn-calendar-ownedItem-btnHide-' + uuid).click(ccn_calendar_owned_ItemSwitchDisplay);
|
||||
$('#ccn-calendar-ownedItem-btnShow-' + uuid).click(ccn_calendar_owned_ItemSwitchDisplay);
|
||||
$('#ccn-calendar-ownedItem-btnUpdate-' + uuid).click(ccn_calendar_owned_ItemUpdate);
|
||||
$('#ccn-calendar-ownedItem-btnCancelUpdate-' + uuid).click(ccn_calendar_owned_ItemCancelUpdate);
|
||||
|
||||
}
|
||||
|
||||
function ccn_calendar_sharing_ChangeDisplayMode(uuid, isShow, isEdit) {
|
||||
function ccn_calendar_owned_ChangeDisplayMode(uuid, isShow, isEdit) {
|
||||
if (typeof(isShow) != 'undefined') {
|
||||
if (isShow) {
|
||||
$('#ccn-calendar-sharingItem-btnHide-' + uuid).show();
|
||||
$('#ccn-calendar-sharingItem-btnShow-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnHide-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnShow-' + uuid).hide();
|
||||
} else {
|
||||
$('#ccn-calendar-sharingItem-btnHide-' + uuid).hide();
|
||||
$('#ccn-calendar-sharingItem-btnShow-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnHide-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnShow-' + uuid).show();
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(isEdit) != 'undefined') {
|
||||
if (isEdit) {
|
||||
$('#ccn-calendar-sharingItem-btnEdit-' + uuid).hide();
|
||||
$('#ccn-calendar-sharingItem-btnShare-' + uuid).hide();
|
||||
$('#ccn-calendar-sharingItem-btnDelete-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnEdit-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnShare-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnDelete-' + uuid).hide();
|
||||
|
||||
$('#ccn-calendar-sharingItem-btnUpdate-' + uuid).show();
|
||||
$('#ccn-calendar-sharingItem-btnCancelUpdate-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnUpdate-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnCancelUpdate-' + uuid).show();
|
||||
|
||||
$('#ccn-admin-userItem-textName-' + uuid).hide();
|
||||
$('#ccn-admin-userItem-boxName-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-textName-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-boxName-' + uuid).show();
|
||||
} else {
|
||||
$('#ccn-calendar-sharingItem-btnEdit-' + uuid).show();
|
||||
$('#ccn-calendar-sharingItem-btnShare-' + uuid).show();
|
||||
$('#ccn-calendar-sharingItem-btnDelete-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnEdit-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnShare-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnDelete-' + uuid).show();
|
||||
|
||||
$('#ccn-calendar-sharingItem-btnUpdate-' + uuid).hide();
|
||||
$('#ccn-calendar-sharingItem-btnCancelUpdate-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnUpdate-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnCancelUpdate-' + uuid).hide();
|
||||
|
||||
$('#ccn-admin-userItem-textName-' + uuid).show();
|
||||
$('#ccn-admin-userItem-boxName-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-textName-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-boxName-' + uuid).hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ccn_calendar_sharingTarget_Refresh() {
|
||||
ccn_calendar_sharingTargetListCache = new Array();
|
||||
function ccn_calendar_sharing_Refresh() {
|
||||
ccn_calendar_sharing_listCache = new Array();
|
||||
|
||||
if (typeof(ccn_calendar_editingSharing) != 'undefined') {
|
||||
var result = ccn_api_collection_getSharing(ccn_calendar_editingSharing);
|
||||
if (typeof(ccn_calendar_sharing_editingOwned) != 'undefined') {
|
||||
var result = ccn_api_collection_getSharing(ccn_calendar_sharing_editingOwned);
|
||||
if (typeof(result) != 'undefined') {
|
||||
for(var index in result) {
|
||||
ccn_calendar_sharingTargetListCache[index] = result[index];
|
||||
ccn_calendar_sharing_listCache[index] = result[index];
|
||||
// also, sharingTarget don't have uuid, use index instead
|
||||
}
|
||||
}
|
||||
|
||||
// update editing text
|
||||
$('#ccn-calendar-sharing-sharingEditing').text(ccn_calendar_sharingListCache[uuid][1]);
|
||||
}
|
||||
|
||||
var listDOM = $('#ccn-calendar-sharingTargetList');
|
||||
// update editing text
|
||||
$('#ccn-calendar-sharing-sharingEditing').text(
|
||||
typeof(ccn_calendar_sharing_editingOwned) == 'undefined' ?
|
||||
'' :
|
||||
ccn_calendar_owned_listCache[ccn_calendar_sharing_editingOwned][1]
|
||||
);
|
||||
|
||||
// if editing is undefined, hide container
|
||||
if (typeof(ccn_calendar_sharing_editingOwned) == 'undefined')
|
||||
$('#ccn-calendar-sharing-container').hide();
|
||||
else
|
||||
$('#ccn-calendar-sharing-container').show();
|
||||
|
||||
|
||||
var listDOM = $('#ccn-calendar-sharingList');
|
||||
listDOM.empty();
|
||||
for(var index in ccn_admin_userListCache) {
|
||||
ccn_admin_userList_RenderItem(
|
||||
ccn_calendar_sharingTargetListCache[index],
|
||||
for(var index in ccn_calendar_sharing_listCache) {
|
||||
ccn_calendar_sharing_RenderItem(
|
||||
ccn_calendar_sharing_listCache[index],
|
||||
index,
|
||||
listDOM
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_sharingTarget_RenderItem(item, index, listDOM) {
|
||||
function ccn_calendar_sharing_RenderItem(item, index, listDOM) {
|
||||
var renderdata = {
|
||||
uuid: index,
|
||||
username: item
|
||||
}
|
||||
|
||||
// render
|
||||
listDOM.append(ccn_template_sharingTargetItem.render(renderdata));
|
||||
listDOM.append(ccn_template_sharingItem.render(renderdata));
|
||||
|
||||
// bind event
|
||||
var uuid = index;
|
||||
$("#ccn-calendar-sharingTargetItem-btnDelete-" + uuid).click(ccn_calendar_sharingTargetList_ItemDelete);
|
||||
$("#ccn-calendar-sharingItem-btnDelete-" + uuid).click(ccn_calendar_sharing_ItemDelete);
|
||||
}
|
||||
|
||||
|
||||
function ccn_calendar_shared_Refresh() {
|
||||
ccn_calendar_sharedListCache = new Array();
|
||||
ccn_calendar_shared_listCache = new Array();
|
||||
ccn_calendar_shared_displayCache = new Array();
|
||||
|
||||
var result = ccn_api_collection_getShared();
|
||||
if (typeof(result) != 'undefined') {
|
||||
for(var index in result) {
|
||||
ccn_calendar_sharedListCache[result[index][0]] = result[index];
|
||||
ccn_calendar_shared_listCache[result[index][0]] = result[index];
|
||||
ccn_calendar_shared_displayCache[result[index][0]] = true;
|
||||
}
|
||||
}
|
||||
@@ -209,18 +227,21 @@ function ccn_calendar_shared_Refresh() {
|
||||
|
||||
var listDOM = $('#ccn-calendar-sharedList');
|
||||
listDOM.empty();
|
||||
for(var index in ccn_calendar_sharedListCache) {
|
||||
var item = ccn_calendar_sharedListCache[index];
|
||||
for(var index in ccn_calendar_shared_listCache) {
|
||||
var item = ccn_calendar_shared_listCache[index];
|
||||
renderdata.uuid = item[0];
|
||||
renderdata.name = item[1];
|
||||
renderdata.username = item[2];
|
||||
|
||||
listDOM.append(ccn_template_sharedItem.render(renderdata));
|
||||
|
||||
// bind event
|
||||
// change display
|
||||
var uuid = renderdata.uuid;
|
||||
$('#ccn-admin-userItem-btnHide-' + uuid).click(ccn_calendar_sharedList_ItemSwitchDisplay);
|
||||
$('#ccn-admin-userItem-btnShow-' + uuid).click(ccn_calendar_sharedList_ItemSwitchDisplay);
|
||||
ccn_calendar_shared_ChangeDisplayMode(uuid, true);
|
||||
|
||||
// bind event
|
||||
$('#ccn-calendar-sharedItem-btnHide-' + uuid).click(ccn_calendar_shared_ItemSwitchDisplay);
|
||||
$('#ccn-calendar-sharedItem-btnShow-' + uuid).click(ccn_calendar_shared_ItemSwitchDisplay);
|
||||
}
|
||||
|
||||
ccn_i18n_ApplyLanguage2Content(listDOM);
|
||||
@@ -228,18 +249,18 @@ function ccn_calendar_shared_Refresh() {
|
||||
|
||||
function ccn_calendar_shared_ChangeDisplayMode(uuid, isShow) {
|
||||
if (isShow) {
|
||||
$('#ccn-admin-userItem-btnHide-' + uuid).show();
|
||||
$('#ccn-admin-userItem-btnShow-' + uuid).hide();
|
||||
$('#ccn-calendar-sharedItem-btnHide-' + uuid).show();
|
||||
$('#ccn-calendar-sharedItem-btnShow-' + uuid).hide();
|
||||
} else {
|
||||
$('#ccn-admin-userItem-btnHide-' + uuid).hide();
|
||||
$('#ccn-admin-userItem-btnShow-' + uuid).show();
|
||||
$('#ccn-calendar-sharedItem-btnHide-' + uuid).hide();
|
||||
$('#ccn-calendar-sharedItem-btnShow-' + uuid).show();
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= input operation
|
||||
|
||||
function ccn_calendar_sharingList_Add() {
|
||||
var newname = $('#ccn-calendar-sharing-inputAdd').val();
|
||||
function ccn_calendar_owned_Add() {
|
||||
var newname = $('#ccn-calendar-owned-inputAdd').val();
|
||||
if (newname == "") return;
|
||||
|
||||
var result = ccn_api_collection_addOwn(newname);
|
||||
@@ -251,122 +272,122 @@ function ccn_calendar_sharingList_Add() {
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-js-fail-get"));
|
||||
else {
|
||||
// render
|
||||
ccn_admin_userListCache[result[0]] = result;
|
||||
var listDOM = $('#ccn-calendar-sharingList');
|
||||
ccn_calendar_sharing_RenderItem(result, listDOM);
|
||||
ccn_calendar_owned_listCache[result[0]] = result;
|
||||
var listDOM = $('#ccn-calendar-ownedList');
|
||||
ccn_calendar_owned_RenderItem(result, listDOM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_sharingList_ItemEdit() {
|
||||
function ccn_calendar_owned_ItemEdit() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
// preset inputbox
|
||||
$('#ccn-admin-userItem-inputName-' + uuid).val(
|
||||
ccn_calendar_sharingListCache[uuid][1]
|
||||
$('#ccn-calendar-ownedItem-inputName-' + uuid).val(
|
||||
ccn_calendar_owned_listCache[uuid][1]
|
||||
);
|
||||
|
||||
// switch to edit mode
|
||||
ccn_calendar_sharing_ChangeDisplayMode(uuid, undefined, true);
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, undefined, true);
|
||||
}
|
||||
|
||||
function ccn_calendar_sharingList_ItemDelete() {
|
||||
function ccn_calendar_owned_ItemDelete() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
var result = ccn_api_collection_deleteOwn(
|
||||
uuid,
|
||||
ccn_calendar_sharingListCache[uuid][2]
|
||||
ccn_calendar_owned_listCache[uuid][2]
|
||||
);
|
||||
if (!result) ccn_messagebox_Show($.i18n.prop("ccn-js-fail-delete"));
|
||||
else {
|
||||
$('#ccn-calendar-sharingItem-' + uuid).remove();
|
||||
$('#ccn-calendar-ownedItem-' + uuid).remove();
|
||||
|
||||
// also, we should notice sharing target, and try clean it
|
||||
if (ccn_calendar_editingSharing == uuid) {
|
||||
ccn_calendar_editingSharing = undefined;
|
||||
ccn_calendar_sharingTarget_Refresh();
|
||||
if (ccn_calendar_sharing_editingOwned == uuid) {
|
||||
ccn_calendar_sharing_editingOwned = undefined;
|
||||
ccn_calendar_sharing_Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_sharingList_ItemUpdate() {
|
||||
function ccn_calendar_owned_ItemUpdate() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
var newname = $('#ccn-admin-userItem-inputName-' + uuid).val();
|
||||
var newname = $('#ccn-calendar-ownedItem-inputName-' + uuid).val();
|
||||
|
||||
var result = ccn_api_collection_updateOwn(uuid, newname, ccn_calendar_sharingListCache[uuid][2]);
|
||||
var result = ccn_api_collection_updateOwn(uuid, newname, ccn_calendar_owned_listCache[uuid][2]);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-js-fail-update"));
|
||||
else {
|
||||
// update last change
|
||||
ccn_calendar_sharingListCache[uuid][2] = result;
|
||||
ccn_calendar_sharingListCache[uuid][1] = newname;
|
||||
ccn_calendar_owned_listCache[uuid][2] = result;
|
||||
ccn_calendar_owned_listCache[uuid][1] = newname;
|
||||
// update elements
|
||||
$('#ccn-admin-userItem-textName-' + uuid).text(newname);
|
||||
$('#ccn-calendar-ownedItem-textName-' + uuid).text(newname);
|
||||
// if editing, update sharing target
|
||||
if (ccn_calendar_editingSharing == uuid)
|
||||
ccn_calendar_sharingTarget_Refresh();
|
||||
if (ccn_calendar_sharing_editingOwned == uuid)
|
||||
ccn_calendar_sharing_Refresh();
|
||||
// back to normal mode
|
||||
ccn_calendar_sharing_ChangeDisplayMode(uuid, undefined, false);
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, undefined, false);
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_sharingList_ItemCancelUpdate() {
|
||||
function ccn_calendar_owned_ItemCancelUpdate() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
ccn_calendar_sharing_ChangeDisplayMode(uuid, undefined, false);
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, undefined, false);
|
||||
}
|
||||
|
||||
function ccn_calendar_sharingList_ItemSwitchDisplay() {
|
||||
function ccn_calendar_owned_ItemSwitchDisplay() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
ccn_calendar_sharing_displayCache[uuid] = !(ccn_calendar_sharing_displayCache[uuid]);
|
||||
ccn_calendar_sharing_ChangeDisplayMode(uuid, ccn_calendar_sharing_displayCache[uuid], undefined);
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, ccn_calendar_sharing_displayCache[uuid], undefined);
|
||||
}
|
||||
|
||||
function ccn_calendar_sharingList_ItemShare() {
|
||||
function ccn_calendar_owned_ItemShare() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
ccn_calendar_editingSharing = uuid;
|
||||
ccn_calendar_sharingTarget_Refresh();
|
||||
ccn_calendar_sharing_editingOwned = uuid;
|
||||
ccn_calendar_sharing_Refresh();
|
||||
}
|
||||
|
||||
|
||||
function ccn_calendar_sharingTargetList_Add() {
|
||||
var newusername = $('#ccn-calendar-sharingTarget-inputAdd').val();
|
||||
if (newusername == "" || typeof(ccn_calendar_editingSharing) == 'undefined') return;
|
||||
function ccn_calendar_sharing_Add() {
|
||||
var newusername = $('#ccn-calendar-sharing-inputAdd').val();
|
||||
if (newusername == "" || typeof(ccn_calendar_sharing_editingOwned) == 'undefined') return;
|
||||
|
||||
var result = ccn_api_collection_addSharing(
|
||||
ccn_calendar_editingSharing,
|
||||
ccn_calendar_sharing_editingOwned,
|
||||
newusername,
|
||||
ccn_calendar_sharingListCache[ccn_calendar_editingSharing][2]
|
||||
ccn_calendar_owned_listCache[ccn_calendar_sharing_editingOwned][2]
|
||||
);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-js-fail-add"));
|
||||
else {
|
||||
// add new item
|
||||
var index = ccn_calendar_sharingTargetListCache.push(newusername) - 1;
|
||||
var listDOM = $('#ccn-calendar-sharingTargetList');
|
||||
ccn_calendar_sharingTarget_RenderItem(newusername, index, listDOM);
|
||||
var index = ccn_calendar_sharing_listCache.push(newusername) - 1;
|
||||
var listDOM = $('#ccn-calendar-sharingList');
|
||||
ccn_calendar_sharing_RenderItem(newusername, index, listDOM);
|
||||
// update last change
|
||||
ccn_calendar_sharingListCache[ccn_calendar_editingSharing][2] = result;
|
||||
ccn_calendar_owned_listCache[ccn_calendar_sharing_editingOwned][2] = result;
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_sharingTargetList_ItemDelete() {
|
||||
function ccn_calendar_sharing_ItemDelete() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
var username = ccn_calendar_sharingTargetListCache[uuid];
|
||||
var username = ccn_calendar_sharing_listCache[uuid];
|
||||
|
||||
var result = ccn_api_collection_deleteSharing(
|
||||
ccn_calendar_editingSharing,
|
||||
ccn_calendar_sharing_editingOwned,
|
||||
username,
|
||||
ccn_calendar_sharingListCache[ccn_calendar_editingSharing][2]
|
||||
ccn_calendar_owned_listCache[ccn_calendar_sharing_editingOwned][2]
|
||||
);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-js-fail-delete"));
|
||||
else {
|
||||
// remove item in ui
|
||||
$('#ccn-calendar-sharingTargetItem-' + uuid).remove();
|
||||
$('#ccn-calendar-sharingItem-' + uuid).remove();
|
||||
// update last change
|
||||
ccn_calendar_sharingListCache[ccn_calendar_editingSharing][2] = result;
|
||||
ccn_calendar_owned_listCache[ccn_calendar_sharing_editingOwned][2] = result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ccn_calendar_sharedList_ItemSwitchDisplay() {
|
||||
function ccn_calendar_shared_ItemSwitchDisplay() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
ccn_calendar_shared_displayCache[uuid] = !(ccn_calendar_shared_displayCache[uuid]);
|
||||
ccn_calendar_shared_ChangeDisplayMode(uuid, ccn_calendar_shared_displayCache[uuid]);
|
||||
|
||||
@@ -2,8 +2,8 @@ var ccn_template_headerNav = undefined;
|
||||
var ccn_template_messagebox = undefined;
|
||||
var ccn_template_calendarItem = undefined;
|
||||
var ccn_template_scheduleItem = undefined;
|
||||
var ccn_template_ownedItem = undefined;
|
||||
var ccn_template_sharingItem = undefined;
|
||||
var ccn_template_sharingTargetItem = undefined;
|
||||
var ccn_template_sharedItem = undefined;
|
||||
var ccn_template_userItem = undefined;
|
||||
var ccn_template_todoItem = undefined;
|
||||
@@ -46,6 +46,14 @@ function ccn_template_Load() {
|
||||
ccn_template_scheduleItem = $.templates(data);
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: $("#jsrender-tmpl-ownedItem").attr('src'),
|
||||
type: "GET",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
ccn_template_ownedItem = $.templates(data);
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: $("#jsrender-tmpl-sharingItem").attr('src'),
|
||||
type: "GET",
|
||||
@@ -54,20 +62,12 @@ function ccn_template_Load() {
|
||||
ccn_template_sharingItem = $.templates(data);
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: $("#jsrender-tmpl-sharingTargetItem").attr('src'),
|
||||
type: "GET",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
ccn_template_scheduleItem = $.templates(data);
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: $("#jsrender-tmpl-sharedItem").attr('src'),
|
||||
type: "GET",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
ccn_template_scheduleItem = $.templates(data);
|
||||
ccn_template_sharedItem = $.templates(data);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
30
src/static/tmpl/ownedItem.tmpl
Normal file
30
src/static/tmpl/ownedItem.tmpl
Normal file
@@ -0,0 +1,30 @@
|
||||
<div id="ccn-calendar-ownedItem-{{:uuid}}" class="collection-item card">
|
||||
<div class="collection-item-words">
|
||||
<p id="ccn-calendar-ownedItem-textName-{{:uuid}}">{{>name}}</p>
|
||||
<div id="ccn-calendar-ownedItem-boxName-{{:uuid}}" class="control">
|
||||
<input id="ccn-calendar-ownedItem-inputName-{{:uuid}}" class="input" type="text"></input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="ccn-calendar-ownedItem-btnEdit-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-pen"></i></span></a>
|
||||
</div>
|
||||
<div id="ccn-calendar-ownedItem-btnShare-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-share"></i></a>
|
||||
</div>
|
||||
<div id="ccn-calendar-ownedItem-btnDelete-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
<div id="ccn-calendar-ownedItem-btnUpdate-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<button class="button"><span class="icon is-small"><i class="fas fa-check"></i></span></button>
|
||||
</div>
|
||||
<div id="ccn-calendar-ownedItem-btnCancelUpdate-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<button class="button"><span class="icon is-small"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<div id="ccn-calendar-ownedItem-btnHide-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-eye"></i></span></a>
|
||||
</div>
|
||||
<div id="ccn-calendar-ownedItem-btnShow-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-eye-slash"></i></span></a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -7,10 +7,10 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="ccn-admin-userItem-btnHide-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<div id="ccn-calendar-sharedItem-btnHide-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-eye"></i></span></a>
|
||||
</div>
|
||||
<div id="ccn-admin-userItem-btnShow-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<div id="ccn-calendar-sharedItem-btnShow-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-eye-slash"></i></span></a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,30 +1,9 @@
|
||||
<div id="ccn-calendar-sharingItem-{{:uuid}}" class="collection-item card">
|
||||
<div class="collection-item-words">
|
||||
<p id="ccn-admin-userItem-textName-{{:uuid}}">{{>name}}</p>
|
||||
<div id="ccn-admin-userItem-boxName-{{:uuid}}" class="control">
|
||||
<input id="ccn-admin-userItem-inputName-{{:uuid}}" class="input" type="text"></input>
|
||||
</div>
|
||||
<p>{{>username}}</p>
|
||||
</div>
|
||||
|
||||
<div id="ccn-calendar-sharingItem-btnEdit-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-pen"></i></span></a>
|
||||
</div>
|
||||
<div id="ccn-calendar-sharingItem-btnShare-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-share"></i></a>
|
||||
</div>
|
||||
<div id="ccn-calendar-sharingItem-btnDelete-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
<div id="ccn-calendar-sharingItem-btnHide-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-eye"></i></span></a>
|
||||
</div>
|
||||
<div id="ccn-calendar-sharingItem-btnShow-{{:uuid}}" uuid="{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-eye-slash"></i></span></a>
|
||||
</div>
|
||||
<div id="ccn-calendar-sharingItem-btnUpdate-{{:uuid}}" uuid="{{:uuid}}" class="todo-item-icon control">
|
||||
<button class="button"><span class="icon is-small"><i class="fas fa-check"></i></span></button>
|
||||
</div>
|
||||
<div id="ccn-calendar-sharingItem-btnCancelUpdate-{{:uuid}}" uuid="{{:uuid}}" class="todo-item-icon control">
|
||||
<button class="button"><span class="icon is-small"><i class="fas fa-times"></i></button>
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-trash"></i></span></a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,9 +0,0 @@
|
||||
<div id="ccn-calendar-sharingTargetItem-{{:uuid}}" class="collection-item card">
|
||||
<div class="collection-item-words">
|
||||
<p>{{>username}}</p>
|
||||
</div>
|
||||
|
||||
<div id="ccn-calendar-sharingTargetItem-btnDelete-{{:uuid}}" class="collection-item-icon control">
|
||||
<a class="button"><span class="icon is-small"><i class="fas fa-trash"></i></span></a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -16,8 +16,8 @@
|
||||
<script type="text/x-jsrender" id="jsrender-tmpl-messagebox" src="/static/tmpl/messagebox.tmpl"></script>
|
||||
<script type="text/x-jsrender" id="jsrender-tmpl-calendarItem" src="/static/tmpl/calendarItem.tmpl"></script>
|
||||
<script type="text/x-jsrender" id="jsrender-tmpl-scheduleItem" src="/static/tmpl/scheduleItem.tmpl"></script>
|
||||
<script type="text/x-jsrender" id="jsrender-tmpl-ownedItem" src="/static/tmpl/ownedItem.tmpl"></script>
|
||||
<script type="text/x-jsrender" id="jsrender-tmpl-sharingItem" src="/static/tmpl/sharingItem.tmpl"></script>
|
||||
<script type="text/x-jsrender" id="jsrender-tmpl-sharingTargetItem" src="/static/tmpl/sharingTargetItem.tmpl"></script>
|
||||
<script type="text/x-jsrender" id="jsrender-tmpl-sharedItem" src="/static/tmpl/sharedItem.tmpl"></script>
|
||||
|
||||
<script type="text/javascript" src="/static/js/localStorageAssist.js"></script>
|
||||
@@ -203,7 +203,36 @@
|
||||
<div id="tabcontrol-panel-1-3" class="container tabcontrol-panel-1" style="margin-top: 20px;">
|
||||
|
||||
<div class="container" style="display: flex; flex-flow: column;">
|
||||
<h1 i18n-name="ccn-calendar-sharing-ownedList" class="title"></h1>
|
||||
<h1 i18n-name="ccn-calendar-ownedList" class="title"></h1>
|
||||
<div class="control-list">
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
<input id="ccn-calendar-owned-inputAdd" class="input" type="text">
|
||||
</div>
|
||||
<div id="ccn-calendar-owned-btnAdd" class="control">
|
||||
<a class="button is-primary">
|
||||
<span class="icon is-small"><i class="fas fa-plus"></i></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="ccn-calendar-own-btnRefresh" class="control">
|
||||
<a class="button is-primary">
|
||||
<span class="icon is-small"><i class="fas fa-sync"></i></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="ccn-calendar-ownedList" style="display: flex; flex-flow: column; margin-top: 1.25rem;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="ccn-calendar-sharing-container" class="container" style="display: flex; flex-flow: column;">
|
||||
<h1 i18n-name="ccn-calendar-sharing-sharingTargetList" class="title"></h1>
|
||||
<label class="label"><span
|
||||
i18n-name="ccn-calendar-sharing-sharingTargetEditing"></span>
|
||||
<span id="ccn-calendar-sharing-sharingEditing"></span>
|
||||
</label>
|
||||
|
||||
<div class="control-list">
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
@@ -226,35 +255,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container" style="display: flex; flex-flow: column;">
|
||||
<h1 i18n-name="ccn-calendar-sharing-sharingTargetList" class="title"></h1>
|
||||
<label class="label"><span
|
||||
i18n-name="ccn-calendar-sharing-sharingTargetEditing"></span>
|
||||
<span id="ccn-calendar-sharing-sharingEditing"></span>
|
||||
</label>
|
||||
|
||||
<div class="control-list">
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
<input id="ccn-calendar-sharingTarget-inputAdd" class="input" type="text">
|
||||
</div>
|
||||
<div id="ccn-calendar-sharingTarget-btnAdd" class="control">
|
||||
<a class="button is-primary">
|
||||
<span class="icon is-small"><i class="fas fa-plus"></i></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="ccn-calendar-sharingTarget-btnRefresh" class="control">
|
||||
<a class="button is-primary">
|
||||
<span class="icon is-small"><i class="fas fa-sync"></i></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="ccn-calendar-sharingTargetList" style="display: flex; flex-flow: column; margin-top: 1.25rem;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user