Compare commits
2 commits
4612128134
...
c6f3d9fd57
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6f3d9fd57 | ||
|
|
c6d868b243 |
|
|
@ -50,11 +50,13 @@
|
||||||
"widget.weekview.controls.week": "Woche",
|
"widget.weekview.controls.week": "Woche",
|
||||||
"widget.weekview.controls.count": "Anzahl",
|
"widget.weekview.controls.count": "Anzahl",
|
||||||
"widget.weekview.controls.apply": "Laden",
|
"widget.weekview.controls.apply": "Laden",
|
||||||
|
"widget.calendar_edit.actions.add": "anlegen",
|
||||||
"widget.calendar_edit.actions.change": "ändern",
|
"widget.calendar_edit.actions.change": "ändern",
|
||||||
"widget.calendar_edit.actions.remove": "löschen",
|
"widget.calendar_edit.actions.remove": "löschen",
|
||||||
"widget.event_edit.actions.add": "anlegen",
|
"widget.event_edit.actions.add": "anlegen",
|
||||||
"widget.event_edit.actions.change": "ändern",
|
"widget.event_edit.actions.change": "ändern",
|
||||||
"widget.event_edit.actions.remove": "löschen",
|
"widget.event_edit.actions.remove": "löschen",
|
||||||
|
"widget.sources.create": "anlegen",
|
||||||
"page.login.title": "Anmelden",
|
"page.login.title": "Anmelden",
|
||||||
"page.login.internal.name": "Name",
|
"page.login.internal.name": "Name",
|
||||||
"page.login.internal.password": "Kennwort",
|
"page.login.internal.password": "Kennwort",
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,13 @@
|
||||||
"widget.weekview.controls.week": "Week",
|
"widget.weekview.controls.week": "Week",
|
||||||
"widget.weekview.controls.count": "Count",
|
"widget.weekview.controls.count": "Count",
|
||||||
"widget.weekview.controls.apply": "Load",
|
"widget.weekview.controls.apply": "Load",
|
||||||
|
"widget.calendar_edit.actions.add": "add",
|
||||||
"widget.calendar_edit.actions.change": "change",
|
"widget.calendar_edit.actions.change": "change",
|
||||||
"widget.calendar_edit.actions.remove": "delete",
|
"widget.calendar_edit.actions.remove": "delete",
|
||||||
"widget.event_edit.actions.add": "add",
|
"widget.event_edit.actions.add": "add",
|
||||||
"widget.event_edit.actions.change": "change",
|
"widget.event_edit.actions.change": "change",
|
||||||
"widget.event_edit.actions.remove": "delete",
|
"widget.event_edit.actions.remove": "delete",
|
||||||
|
"widget.sources.create": "create",
|
||||||
"page.login.title": "Login",
|
"page.login.title": "Login",
|
||||||
"page.login.internal.name": "name",
|
"page.login.internal.name": "name",
|
||||||
"page.login.internal.password": "password",
|
"page.login.internal.password": "password",
|
||||||
|
|
|
||||||
|
|
@ -82,23 +82,11 @@ namespace _dali
|
||||||
"label": lib_plankton.translate.get("page.overview.title"),
|
"label": lib_plankton.translate.get("page.overview.title"),
|
||||||
"groups": ["logged_out", "logged_in"],
|
"groups": ["logged_out", "logged_in"],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"location": {"name": "calendar_add", "parameters": {}},
|
|
||||||
"label": lib_plankton.translate.get("page.calendar_add.title"),
|
|
||||||
"groups": ["logged_in"],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"location": {"name": "caldav", "parameters": {}},
|
"location": {"name": "caldav", "parameters": {}},
|
||||||
"label": lib_plankton.translate.get("page.caldav.title"),
|
"label": lib_plankton.translate.get("page.caldav.title"),
|
||||||
"groups": ["logged_in"],
|
"groups": ["logged_in"],
|
||||||
},
|
},
|
||||||
/*
|
|
||||||
{
|
|
||||||
"location": {"name": "event_add", "parameters": {}},
|
|
||||||
"label": lib_plankton.translate.get("page.event_add.title"),
|
|
||||||
"groups": ["logged_in"],
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
"location": {"name": "logout", "parameters": {}},
|
"location": {"name": "logout", "parameters": {}},
|
||||||
"label": lib_plankton.translate.get("page.logout.title"),
|
"label": lib_plankton.translate.get("page.logout.title"),
|
||||||
|
|
|
||||||
|
|
@ -1,228 +0,0 @@
|
||||||
namespace _dali.pages
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
lib_plankton.zoo_page.register(
|
|
||||||
"calendar_add",
|
|
||||||
async (parameters, target_element) => {
|
|
||||||
target_element.innerHTML = "";
|
|
||||||
target_element.innerHTML = await _dali.helpers.template_coin(
|
|
||||||
"calendar_add",
|
|
||||||
"default",
|
|
||||||
{
|
|
||||||
"label": lib_plankton.translate.get("page.calendar_add.title")
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const form : lib_plankton.zoo_form.class_form<
|
|
||||||
{
|
|
||||||
name : string;
|
|
||||||
access : {
|
|
||||||
public : boolean;
|
|
||||||
default_level : _dali.type.enum_access_level;
|
|
||||||
attributed : lib_plankton.map.type_map<
|
|
||||||
_dali.type.user_id,
|
|
||||||
_dali.type.enum_access_level
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
resource_kind : string;
|
|
||||||
hue : (null | float);
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : string;
|
|
||||||
access : {
|
|
||||||
public : boolean;
|
|
||||||
default_level : _dali.type.enum_access_level;
|
|
||||||
attributed : lib_plankton.map.type_map<
|
|
||||||
_dali.type.user_id,
|
|
||||||
_dali.type.enum_access_level
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
resource_kind : string;
|
|
||||||
hue : (null | float);
|
|
||||||
}
|
|
||||||
> = new lib_plankton.zoo_form.class_form<
|
|
||||||
{
|
|
||||||
name : string;
|
|
||||||
access : {
|
|
||||||
public : boolean;
|
|
||||||
default_level : _dali.type.enum_access_level;
|
|
||||||
attributed : lib_plankton.map.type_map<
|
|
||||||
_dali.type.user_id,
|
|
||||||
_dali.type.enum_access_level
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
resource_kind : string;
|
|
||||||
hue : (null | float);
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name : string;
|
|
||||||
access : {
|
|
||||||
public : boolean;
|
|
||||||
default_level : _dali.type.enum_access_level;
|
|
||||||
attributed : lib_plankton.map.type_map<
|
|
||||||
_dali.type.user_id,
|
|
||||||
_dali.type.enum_access_level
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
resource_kind : string;
|
|
||||||
hue : (null | float);
|
|
||||||
}
|
|
||||||
>(
|
|
||||||
(value) => value,
|
|
||||||
(raw) => raw,
|
|
||||||
new lib_plankton.zoo_input.class_input_group<any>(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "name",
|
|
||||||
"input": new lib_plankton.zoo_input.class_input_text(),
|
|
||||||
"label": lib_plankton.translate.get("calendar.name")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "hue",
|
|
||||||
"input": new lib_plankton.zoo_input.class_input_hue(
|
|
||||||
),
|
|
||||||
"label": lib_plankton.translate.get("calendar.hue"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "access",
|
|
||||||
"input": new lib_plankton.zoo_input.class_input_group(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "public",
|
|
||||||
"input": new lib_plankton.zoo_input.class_input_checkbox(),
|
|
||||||
"label": lib_plankton.translate.get("calendar.access.public"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "default_level",
|
|
||||||
"input": _dali.helpers.input_access_level(),
|
|
||||||
"label": lib_plankton.translate.get("calendar.access.default_level"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "attributed",
|
|
||||||
"input": await _dali.helpers.input_attributed_access(),
|
|
||||||
"label": lib_plankton.translate.get("calendar.access.attributed"),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
),
|
|
||||||
"label": lib_plankton.translate.get("calendar.access.access"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "resource_kind",
|
|
||||||
"input": new lib_plankton.zoo_input.class_input_selection(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"value": "local",
|
|
||||||
"label": lib_plankton.translate.get("resource.kinds.local.title")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "caldav",
|
|
||||||
"label": lib_plankton.translate.get("resource.kinds.caldav.title")
|
|
||||||
},
|
|
||||||
]
|
|
||||||
),
|
|
||||||
"label": lib_plankton.translate.get("resource.kind")
|
|
||||||
},
|
|
||||||
]
|
|
||||||
),
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"label": lib_plankton.translate.get("page.calendar_add.actions.do"),
|
|
||||||
"procedure": async (get_value, get_representation) => {
|
|
||||||
const value : any = await get_value();
|
|
||||||
const calendar_object : _dali.type.calendar_object = {
|
|
||||||
"name": value.name,
|
|
||||||
"access": {
|
|
||||||
"public": value.access.public,
|
|
||||||
"default_level": value.access.default_level,
|
|
||||||
"attributed": value.access.attributed,
|
|
||||||
},
|
|
||||||
"resource": (() => {
|
|
||||||
switch (value.resource_kind) {
|
|
||||||
case "local":
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"kind": "local",
|
|
||||||
"data": {
|
|
||||||
"events": [],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "caldav":
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"kind": "caldav",
|
|
||||||
"data": {
|
|
||||||
"url": "", // TODO
|
|
||||||
"read_only": true, // TODO
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
throw (new Error("invalid resource kind: " + value.resource_kind));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) (),
|
|
||||||
"hue": value.hue,
|
|
||||||
};
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await _dali.backend.calendar_add(
|
|
||||||
calendar_object
|
|
||||||
);
|
|
||||||
lib_plankton.zoo_page.set(
|
|
||||||
{
|
|
||||||
"name": "overview",
|
|
||||||
"parameters": {}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
catch (error)
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
/*
|
|
||||||
lib_plankton.zoo_page.set(
|
|
||||||
{
|
|
||||||
"name": "event_add",
|
|
||||||
"parameters": {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
|
||||||
);
|
|
||||||
await form.setup(document.querySelector("#calendar_add_form"));
|
|
||||||
await form.input_write(
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"access": {
|
|
||||||
"public": false,
|
|
||||||
"default_level": _dali.type.enum_access_level.view,
|
|
||||||
"attributed": lib_plankton.map.hashmap.implementation_map<
|
|
||||||
_dali.type.user_id,
|
|
||||||
_dali.type.enum_access_level
|
|
||||||
>(
|
|
||||||
lib_plankton.map.hashmap.make<
|
|
||||||
_dali.type.user_id,
|
|
||||||
_dali.type.enum_access_level
|
|
||||||
>(
|
|
||||||
user_id => user_id.toFixed(0),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
},
|
|
||||||
"resource_kind": "local",
|
|
||||||
"hue": lib_plankton.random.generate_unit(),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return Promise.resolve<void>(undefined);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
<div id="calendar_add">
|
|
||||||
<h2>{{label}}</h2>
|
|
||||||
<div id="calendar_add_form">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
namespace _dali.pages
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
lib_plankton.zoo_page.register(
|
|
||||||
"calendar_edit",
|
|
||||||
async (parameters, target_element) => {
|
|
||||||
const read_only : boolean = ((parameters["read_only"] ?? "yes") === "yes");
|
|
||||||
const calendar_id : int = parseInt(parameters["calendar_id"]);
|
|
||||||
target_element.innerHTML = "";
|
|
||||||
target_element.innerHTML = await _dali.helpers.template_coin(
|
|
||||||
"calendar_edit",
|
|
||||||
"default",
|
|
||||||
{
|
|
||||||
"label": lib_plankton.translate.get("page.calendar_edit.title.regular")
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const calendar_object : _dali.type.calendar_object = await _dali.backend.calendar_get(
|
|
||||||
calendar_id
|
|
||||||
);
|
|
||||||
const widget = new _dali.widgets.calendar_edit.class_widget_calendar_edit(
|
|
||||||
{
|
|
||||||
"read_only": read_only,
|
|
||||||
"action_change": (data) => {
|
|
||||||
_dali.backend.calendar_change(
|
|
||||||
calendar_id,
|
|
||||||
data
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
() => {
|
|
||||||
lib_plankton.zoo_page.set(
|
|
||||||
{
|
|
||||||
"name": "overview",
|
|
||||||
"parameters": {}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
"action_remove": (data) => {
|
|
||||||
_dali.backend.calendar_remove(
|
|
||||||
calendar_id
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
() => {
|
|
||||||
lib_plankton.zoo_page.set(
|
|
||||||
{
|
|
||||||
"name": "overview",
|
|
||||||
"parameters": {}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
"initial_value": {
|
|
||||||
"name": calendar_object.name,
|
|
||||||
"hue": calendar_object.hue,
|
|
||||||
"access": calendar_object.access,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
await widget.load(document.querySelector("#calendar_edit_form"));
|
|
||||||
return Promise.resolve<void>(undefined);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
<div id="calendar_edit">
|
|
||||||
<h2>{{label}}</h2>
|
|
||||||
<div id="calendar_edit_form">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
@ -57,13 +57,15 @@ namespace _dali.pages.overview
|
||||||
await widget_mode_switcher.load(target_element.querySelector("#overview-mode"));
|
await widget_mode_switcher.load(target_element.querySelector("#overview-mode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let widget_sources : _dali.widgets.sources.class_widget_sources;
|
||||||
let widget_weekview : _dali.widgets.weekview.class_widget_weekview;
|
let widget_weekview : _dali.widgets.weekview.class_widget_weekview;
|
||||||
let widget_listview : _dali.widgets.listview.class_widget_listview;
|
let widget_listview : _dali.widgets.listview.class_widget_listview;
|
||||||
/**
|
/**
|
||||||
* @todo update sources
|
* @todo update sources
|
||||||
*/
|
*/
|
||||||
const update = () => {
|
const update = async () => {
|
||||||
widget_weekview.update_entries();
|
await widget_weekview.update_entries();
|
||||||
|
await widget_sources.update();
|
||||||
};
|
};
|
||||||
// hint
|
// hint
|
||||||
{
|
{
|
||||||
|
|
@ -78,18 +80,54 @@ namespace _dali.pages.overview
|
||||||
}
|
}
|
||||||
// sources
|
// sources
|
||||||
{
|
{
|
||||||
const data : Array<
|
widget_sources = new _dali.widgets.sources.class_widget_sources(
|
||||||
{
|
_dali.backend.calendar_list,
|
||||||
id : _dali.type.calendar_id;
|
|
||||||
name : string;
|
|
||||||
hue : float;
|
|
||||||
access_level : _dali.type.enum_access_level;
|
|
||||||
}
|
|
||||||
> = await _dali.backend.calendar_list(
|
|
||||||
);
|
|
||||||
const widget_sources = new _dali.widgets.sources.class_widget_sources(
|
|
||||||
data,
|
|
||||||
{
|
{
|
||||||
|
"action_create": () => {
|
||||||
|
(async () => {
|
||||||
|
const widget = new _dali.widgets.calendar_edit.class_widget_calendar_edit(
|
||||||
|
{
|
||||||
|
"read_only": false,
|
||||||
|
"action_cancel": () => {
|
||||||
|
_dali.overlay.toggle({"mode": false});
|
||||||
|
},
|
||||||
|
"action_add": (data) => {
|
||||||
|
_dali.backend.calendar_add(
|
||||||
|
{
|
||||||
|
"name": data.name,
|
||||||
|
"hue": data.hue,
|
||||||
|
"access": data.access,
|
||||||
|
"resource": {
|
||||||
|
"kind": "local",
|
||||||
|
"data": {
|
||||||
|
"events": [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
() => {
|
||||||
|
update();
|
||||||
|
_dali.overlay.toggle({"mode": false});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.catch(
|
||||||
|
(reason) => {
|
||||||
|
lib_plankton.log.warning(
|
||||||
|
"dali.overview.calendar_add_error",
|
||||||
|
{"details": String(reason)}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
"initial_value": null,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
_dali.overlay.clear();
|
||||||
|
_dali.overlay.toggle({"mode": true});
|
||||||
|
await widget.load(_dali.overlay.get_content_element());
|
||||||
|
}) ();
|
||||||
|
},
|
||||||
"action_open": (entry) => {
|
"action_open": (entry) => {
|
||||||
let read_only : boolean;
|
let read_only : boolean;
|
||||||
switch (entry.access_level)
|
switch (entry.access_level)
|
||||||
|
|
|
||||||
|
|
@ -89,12 +89,14 @@ nav a:hover
|
||||||
a
|
a
|
||||||
{
|
{
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: hsl(var(--hue), 50%, 50%);
|
color: hsl(var(--hue), 0%, 87.5%);
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover
|
a:hover
|
||||||
{
|
{
|
||||||
color: hsl(var(--hue), 50%, 75%);
|
color: hsl(var(--hue), 0%, 100%);
|
||||||
|
border-bottom: 2px solid hsl(0, 0%, 100%);
|
||||||
|
transition: 1s ease color;
|
||||||
}
|
}
|
||||||
|
|
||||||
input,select,textarea
|
input,select,textarea
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
.sources
|
.sources
|
||||||
|
{
|
||||||
|
font-size: 0.75em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sources-entries
|
||||||
{
|
{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
font-size: 0.75em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sources-entry
|
.sources-entry
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,11 @@ namespace _dali.widgets.calendar_edit
|
||||||
private action_cancel ?: (null | (() => void));
|
private action_cancel ?: (null | (() => void));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private action_add ?: (null | ((value : type_value) => void));
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
private action_change ?: (null | ((value : type_value) => void));
|
private action_change ?: (null | ((value : type_value) => void));
|
||||||
|
|
@ -54,6 +59,7 @@ namespace _dali.widgets.calendar_edit
|
||||||
{
|
{
|
||||||
"read_only": read_only = false,
|
"read_only": read_only = false,
|
||||||
"action_cancel": action_cancel = null,
|
"action_cancel": action_cancel = null,
|
||||||
|
"action_add": action_add = null,
|
||||||
"action_change": action_change = null,
|
"action_change": action_change = null,
|
||||||
"action_remove": action_remove = null,
|
"action_remove": action_remove = null,
|
||||||
"initial_value": initial_value = null,
|
"initial_value": initial_value = null,
|
||||||
|
|
@ -62,6 +68,7 @@ namespace _dali.widgets.calendar_edit
|
||||||
{
|
{
|
||||||
read_only ?: boolean;
|
read_only ?: boolean;
|
||||||
action_cancel ?: (null | (() => void));
|
action_cancel ?: (null | (() => void));
|
||||||
|
action_add ?: (null | ((value : type_value) => void))
|
||||||
action_change ?: (null | ((value : type_value) => void));
|
action_change ?: (null | ((value : type_value) => void));
|
||||||
action_remove ?: (null | ((value : type_value) => void));
|
action_remove ?: (null | ((value : type_value) => void));
|
||||||
initial_value ?: (null | type_value);
|
initial_value ?: (null | type_value);
|
||||||
|
|
@ -73,6 +80,7 @@ namespace _dali.widgets.calendar_edit
|
||||||
{
|
{
|
||||||
this.read_only = read_only;
|
this.read_only = read_only;
|
||||||
this.action_cancel = action_cancel;
|
this.action_cancel = action_cancel;
|
||||||
|
this.action_add = action_add;
|
||||||
this.action_change = action_change;
|
this.action_change = action_change;
|
||||||
this.action_remove = action_remove;
|
this.action_remove = action_remove;
|
||||||
this.initial_value = initial_value;
|
this.initial_value = initial_value;
|
||||||
|
|
@ -150,6 +158,22 @@ namespace _dali.widgets.calendar_edit
|
||||||
:
|
:
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
// add
|
||||||
|
.concat(
|
||||||
|
((! this.read_only) && (! (this.action_add === null)))
|
||||||
|
?
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"label": lib_plankton.translate.get("widget.calendar_edit.actions.add"),
|
||||||
|
"procedure": async (get_value, get_representation) => {
|
||||||
|
const value : type_value = await get_value();
|
||||||
|
this.action_add(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
:
|
||||||
|
[]
|
||||||
|
)
|
||||||
// change
|
// change
|
||||||
.concat(
|
.concat(
|
||||||
((! this.read_only) && (! (this.action_change === null)))
|
((! this.read_only) && (! (this.action_change === null)))
|
||||||
|
|
|
||||||
|
|
@ -17,53 +17,230 @@ namespace _dali.widgets.sources
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* [dependency]
|
||||||
*/
|
*/
|
||||||
private keys : Array<string>;
|
private get_entries : (() => Promise<Array<type_entry>>);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
private data : Record<string, type_entry>;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* [hook]
|
||||||
*/
|
*/
|
||||||
private action_open : ((entry : type_entry) => void);
|
private action_open : ((entry : type_entry) => void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* [hook]
|
||||||
*/
|
*/
|
||||||
private action_toggle_visibility : ((entry : type_entry) => void);
|
private action_toggle_visibility : ((entry : type_entry) => void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [hook]
|
||||||
|
*/
|
||||||
|
private action_create : (() => void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [state]
|
||||||
|
*/
|
||||||
|
private container : (null | Element);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor(
|
||||||
entries : Array<type_entry>,
|
get_entries : (() => Promise<Array<type_entry>>),
|
||||||
options : {
|
{
|
||||||
|
"action_open": action_open = ((calendar_id) => {}),
|
||||||
|
"action_toggle_visibility": action_toggle_visibility = ((calendar_id) => {}),
|
||||||
|
"action_create": action_create = (() => {}),
|
||||||
|
}
|
||||||
|
:
|
||||||
|
{
|
||||||
action_open ?: ((entry : type_entry) => void);
|
action_open ?: ((entry : type_entry) => void);
|
||||||
action_toggle_visibility ?: ((entry : type_entry) => void);
|
action_toggle_visibility ?: ((entry : type_entry) => void);
|
||||||
} = {}
|
action_create ?: (() => void);
|
||||||
|
}
|
||||||
|
=
|
||||||
|
{
|
||||||
|
}
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
options = Object.assign(
|
// dependencies
|
||||||
{
|
this.get_entries = get_entries;
|
||||||
"action_open": (calendar_id) => {},
|
|
||||||
"action_toggle_visibility": (calendar_id) => {},
|
// hooks
|
||||||
},
|
this.action_open = action_open;
|
||||||
options
|
this.action_toggle_visibility = action_toggle_visibility;
|
||||||
|
this.action_create = action_create;
|
||||||
|
|
||||||
|
// state
|
||||||
|
this.container = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private static id_encode(
|
||||||
|
id : _dali.type.calendar_id
|
||||||
|
)
|
||||||
|
: string
|
||||||
|
{
|
||||||
|
return id.toFixed(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private static id_decode(
|
||||||
|
representation : string
|
||||||
|
)
|
||||||
|
: _dali.type.calendar_id
|
||||||
|
{
|
||||||
|
return parseInt(representation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public async update(
|
||||||
|
)
|
||||||
|
: Promise<void>
|
||||||
|
{
|
||||||
|
const data : lib_plankton.map.type_map<_dali.type.calendar_id, type_entry> = lib_plankton.map.hashmap.implementation_map(
|
||||||
|
lib_plankton.map.hashmap.make(
|
||||||
|
calendar_id => class_widget_sources.id_encode(calendar_id),
|
||||||
|
{
|
||||||
|
"pairs": (
|
||||||
|
(await this.get_entries())
|
||||||
|
.map(
|
||||||
|
entry => ({
|
||||||
|
"key": entry.id,
|
||||||
|
"value": entry,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
this.keys = [];
|
// structure
|
||||||
this.data = {};
|
{
|
||||||
entries.forEach(
|
this.container.innerHTML = await _dali.helpers.template_coin(
|
||||||
(entry) => {
|
"widget-sources",
|
||||||
const key : string = entry.id.toFixed(0);
|
"main",
|
||||||
this.keys.push(key);
|
{
|
||||||
this.data[key] = entry;
|
"label_create": lib_plankton.translate.get("widget.sources.create"),
|
||||||
}
|
"entries": (
|
||||||
);
|
(
|
||||||
this.action_open = options.action_open;
|
await _dali.helpers.promise_row<string>(
|
||||||
this.action_toggle_visibility = options.action_toggle_visibility;
|
lib_plankton.map.dump(data)
|
||||||
|
.map(
|
||||||
|
(pair) => () => {
|
||||||
|
return _dali.helpers.template_coin(
|
||||||
|
"widget-sources",
|
||||||
|
"entry",
|
||||||
|
{
|
||||||
|
"name": pair.value.name,
|
||||||
|
"label_toggle": lib_plankton.string.coin(
|
||||||
|
"{{show}}/{{hide}}",
|
||||||
|
{
|
||||||
|
"show": lib_plankton.translate.get("common.show"),
|
||||||
|
"hide": lib_plankton.translate.get("common.hide"),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
"label_edit": lib_plankton.translate.get("common.edit"),
|
||||||
|
// "access_level": entry.access_level, // TODO
|
||||||
|
// TODO centralize
|
||||||
|
"color_head": lib_plankton.color.output_hex(
|
||||||
|
lib_plankton.color.make_hsv(
|
||||||
|
{
|
||||||
|
"hue": pair.value.hue,
|
||||||
|
/**
|
||||||
|
* @todo const and outsource
|
||||||
|
*/
|
||||||
|
"saturation": 0.375,
|
||||||
|
/**
|
||||||
|
* @todo const and outsource
|
||||||
|
*/
|
||||||
|
"value": 0.375,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
),
|
||||||
|
"color_body": lib_plankton.color.output_hex(
|
||||||
|
lib_plankton.color.make_hsv(
|
||||||
|
{
|
||||||
|
"hue": pair.value.hue,
|
||||||
|
/**
|
||||||
|
* @todo const and outsource
|
||||||
|
*/
|
||||||
|
"saturation": 0.375,
|
||||||
|
/**
|
||||||
|
* @todo const and outsource
|
||||||
|
*/
|
||||||
|
"value": 0.25,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
),
|
||||||
|
"rel": class_widget_sources.id_encode(pair.key),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.join("")
|
||||||
|
),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// listeners
|
||||||
|
{
|
||||||
|
this.container.querySelector(".sources-create").addEventListener(
|
||||||
|
"click",
|
||||||
|
(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
this.action_create();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.container.querySelectorAll(".sources-entry-head").forEach(
|
||||||
|
(element) => {
|
||||||
|
element.addEventListener(
|
||||||
|
"click",
|
||||||
|
(event) => {
|
||||||
|
element.parentElement.classList.toggle("sources-entry-open");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.container.querySelectorAll(".sources-entry-toggle").forEach(
|
||||||
|
(element) => {
|
||||||
|
element.addEventListener(
|
||||||
|
"click",
|
||||||
|
() => {
|
||||||
|
const key_encoded : string = element.parentElement.parentElement.parentElement.getAttribute("rel");
|
||||||
|
const calendar_id : _dali.type.calendar_id = class_widget_sources.id_decode(key_encoded);
|
||||||
|
const entry : type_entry = data.get(calendar_id);
|
||||||
|
element.parentElement.parentElement.parentElement.classList.toggle("sources-entry-hidden");
|
||||||
|
element.parentElement.parentElement.parentElement.classList.toggle("sources-entry-open", false);
|
||||||
|
this.action_toggle_visibility(entry);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.container.querySelectorAll(".sources-entry-edit").forEach(
|
||||||
|
(element) => {
|
||||||
|
element.addEventListener(
|
||||||
|
"click",
|
||||||
|
(event) => {
|
||||||
|
const key_encoded : string = element.parentElement.parentElement.parentElement.getAttribute("rel");
|
||||||
|
const calendar_id : _dali.type.calendar_id = class_widget_sources.id_decode(key_encoded);
|
||||||
|
const entry : type_entry = data.get(calendar_id);
|
||||||
|
this.action_open(entry);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -72,100 +249,11 @@ namespace _dali.widgets.sources
|
||||||
*/
|
*/
|
||||||
public async load(
|
public async load(
|
||||||
target_element : Element
|
target_element : Element
|
||||||
) : Promise<void>
|
)
|
||||||
|
: Promise<void>
|
||||||
{
|
{
|
||||||
target_element.innerHTML = await _dali.helpers.template_coin(
|
this.container = target_element;
|
||||||
"widget-sources",
|
await this.update();
|
||||||
"main",
|
|
||||||
{
|
|
||||||
"entries": (
|
|
||||||
(
|
|
||||||
await _dali.helpers.promise_row<string>(
|
|
||||||
this.keys
|
|
||||||
.map(
|
|
||||||
(key) => () => {
|
|
||||||
const entry : type_entry = this.data[key];
|
|
||||||
return _dali.helpers.template_coin(
|
|
||||||
"widget-sources",
|
|
||||||
"entry",
|
|
||||||
{
|
|
||||||
"name": entry.name,
|
|
||||||
"label_toggle": lib_plankton.string.coin(
|
|
||||||
"{{show}}/{{hide}}",
|
|
||||||
{
|
|
||||||
"show": lib_plankton.translate.get("common.show"),
|
|
||||||
"hide": lib_plankton.translate.get("common.hide"),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"label_edit": lib_plankton.translate.get("common.edit"),
|
|
||||||
// "access_level": entry.access_level, // TODO
|
|
||||||
// TODO centralize
|
|
||||||
"color_head": lib_plankton.color.output_hex(
|
|
||||||
lib_plankton.color.make_hsv(
|
|
||||||
{
|
|
||||||
"hue": entry.hue,
|
|
||||||
"saturation": 0.375,
|
|
||||||
"value": 0.375,
|
|
||||||
}
|
|
||||||
),
|
|
||||||
),
|
|
||||||
"color_body": lib_plankton.color.output_hex(
|
|
||||||
lib_plankton.color.make_hsv(
|
|
||||||
{
|
|
||||||
"hue": entry.hue,
|
|
||||||
"saturation": 0.375,
|
|
||||||
"value": 0.25,
|
|
||||||
}
|
|
||||||
),
|
|
||||||
),
|
|
||||||
"rel": key,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.join("")
|
|
||||||
),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
target_element.querySelectorAll(".sources-entry-head").forEach(
|
|
||||||
(element) => {
|
|
||||||
element.addEventListener(
|
|
||||||
"click",
|
|
||||||
(event) => {
|
|
||||||
element.parentElement.classList.toggle("sources-entry-open");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
target_element.querySelectorAll(".sources-entry-toggle").forEach(
|
|
||||||
(element) => {
|
|
||||||
element.addEventListener(
|
|
||||||
"click",
|
|
||||||
() => {
|
|
||||||
const key : string = element.parentElement.parentElement.parentElement.getAttribute("rel");
|
|
||||||
const entry : type_entry = this.data[key];
|
|
||||||
element.parentElement.parentElement.parentElement.classList.toggle("sources-entry-hidden");
|
|
||||||
element.parentElement.parentElement.parentElement.classList.toggle("sources-entry-open", false);
|
|
||||||
this.action_toggle_visibility(entry);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
target_element.querySelectorAll(".sources-entry-edit").forEach(
|
|
||||||
(element) => {
|
|
||||||
element.addEventListener(
|
|
||||||
"click",
|
|
||||||
(event) => {
|
|
||||||
const key : string = element.parentElement.parentElement.parentElement.getAttribute("rel");
|
|
||||||
const entry : type_entry = this.data[key];
|
|
||||||
this.action_open(entry);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return Promise.resolve<void>(undefined);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
<ul class="sources">
|
<div class="sources">
|
||||||
{{entries}}
|
<ul class="sources-entries">
|
||||||
</ul>
|
{{entries}}
|
||||||
|
</ul>
|
||||||
|
<a class="sources-create" href="">{{label_create}}</a>
|
||||||
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,6 @@ templates: \
|
||||||
templates-widgets-calendar_edit \
|
templates-widgets-calendar_edit \
|
||||||
templates-widgets-event_edit \
|
templates-widgets-event_edit \
|
||||||
templates-pages-caldav \
|
templates-pages-caldav \
|
||||||
templates-pages-calendar_add \
|
|
||||||
templates-pages-calendar_edit \
|
|
||||||
templates-pages-overview \
|
templates-pages-overview \
|
||||||
templates-pages-login
|
templates-pages-login
|
||||||
|
|
||||||
|
|
@ -93,20 +91,6 @@ templates-pages-caldav: \
|
||||||
@ ${cmd_mkdir} ${dir_build}/templates/caldav
|
@ ${cmd_mkdir} ${dir_build}/templates/caldav
|
||||||
@ ${cmd_cp} -r -u -v ${dir_source}/pages/caldav/templates/* ${dir_build}/templates/caldav/
|
@ ${cmd_cp} -r -u -v ${dir_source}/pages/caldav/templates/* ${dir_build}/templates/caldav/
|
||||||
|
|
||||||
.PHONY: templates-pages-calendar_add
|
|
||||||
templates-pages-calendar_add: \
|
|
||||||
$(wildcard ${dir_source}/pages/calendar_add/templates/*)
|
|
||||||
@ ${cmd_log} "templates:calendar_add …"
|
|
||||||
@ ${cmd_mkdir} ${dir_build}/templates/calendar_add
|
|
||||||
@ ${cmd_cp} -r -u -v ${dir_source}/pages/calendar_add/templates/* ${dir_build}/templates/calendar_add/
|
|
||||||
|
|
||||||
.PHONY: templates-pages-calendar_edit
|
|
||||||
templates-pages-calendar_edit: \
|
|
||||||
$(wildcard ${dir_source}/pages/calendar_edit/templates/*)
|
|
||||||
@ ${cmd_log} "templates:calendar_edit …"
|
|
||||||
@ ${cmd_mkdir} ${dir_build}/templates/calendar_edit
|
|
||||||
@ ${cmd_cp} -r -u -v ${dir_source}/pages/calendar_edit/templates/* ${dir_build}/templates/calendar_edit/
|
|
||||||
|
|
||||||
.PHONY: templates-pages-overview
|
.PHONY: templates-pages-overview
|
||||||
templates-pages-overview: \
|
templates-pages-overview: \
|
||||||
$(wildcard ${dir_source}/pages/overview/templates/*)
|
$(wildcard ${dir_source}/pages/overview/templates/*)
|
||||||
|
|
@ -150,8 +134,6 @@ ${dir_temp}/logic-unlinked.js: \
|
||||||
${dir_source}/pages/logout/logic.ts \
|
${dir_source}/pages/logout/logic.ts \
|
||||||
${dir_source}/pages/caldav/logic.ts \
|
${dir_source}/pages/caldav/logic.ts \
|
||||||
${dir_source}/pages/oidc_finish/logic.ts \
|
${dir_source}/pages/oidc_finish/logic.ts \
|
||||||
${dir_source}/pages/calendar_add/logic.ts \
|
|
||||||
${dir_source}/pages/calendar_edit/logic.ts \
|
|
||||||
${dir_source}/pages/overview/logic.ts \
|
${dir_source}/pages/overview/logic.ts \
|
||||||
${dir_source}/main.ts
|
${dir_source}/main.ts
|
||||||
@ ${cmd_log} "logic | compile …"
|
@ ${cmd_log} "logic | compile …"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue