Gruppen-Steuerung #3
3
lib/plankton/plankton.d.ts
vendored
3
lib/plankton/plankton.d.ts
vendored
|
|
@ -882,6 +882,9 @@ declare namespace lib_plankton.call {
|
|||
/**
|
||||
*/
|
||||
export function sleep(seconds: float): Promise<void>;
|
||||
/**
|
||||
*/
|
||||
export function null_prop<type_value_from, type_value_to>(value_from: (null | type_value_from), function_: ((value: type_value_from) => type_value_to)): (null | type_value_to);
|
||||
export {};
|
||||
}
|
||||
declare namespace lib_plankton.file {
|
||||
|
|
|
|||
|
|
@ -2043,6 +2043,16 @@ var lib_plankton;
|
|||
}));
|
||||
}
|
||||
call.sleep = sleep;
|
||||
/**
|
||||
*/
|
||||
function null_prop(value_from, function_) {
|
||||
return ((value_from === null)
|
||||
?
|
||||
null
|
||||
:
|
||||
function_(value_from));
|
||||
}
|
||||
call.null_prop = null_prop;
|
||||
})(call = lib_plankton.call || (lib_plankton.call = {}));
|
||||
})(lib_plankton || (lib_plankton = {}));
|
||||
/*
|
||||
|
|
@ -3792,10 +3802,10 @@ var lib_plankton;
|
|||
options = Object.assign({
|
||||
"compare_value": instance_compare
|
||||
}, options);
|
||||
if (is_empty(list)) {
|
||||
/*if (is_empty<type_element>(list)) {
|
||||
throw (new Error("the max-arg of an empty list is not defined"));
|
||||
}
|
||||
else {
|
||||
else */ {
|
||||
return (list
|
||||
.reduce(function (result, element, index) {
|
||||
var value = target_function(element);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@
|
|||
"calendar.access.access": "Zugriff",
|
||||
"calendar.access.public": "öffentlich",
|
||||
"calendar.access.default_level": "Standard",
|
||||
"calendar.access.attributed": "Zuweisungen",
|
||||
"calendar.access.attributed_group": "Gruppen-Zuweisungen",
|
||||
"calendar.access.attributed_user": "Nutzer-Zuweisungen",
|
||||
"widget.listview.add": "Termin anlegen",
|
||||
"widget.weekview.controls.year": "Jahr",
|
||||
"widget.weekview.controls.week": "Woche",
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@
|
|||
"calendar.access.access": "access",
|
||||
"calendar.access.public": "public",
|
||||
"calendar.access.default_level": "default",
|
||||
"calendar.access.attributed": "attributed",
|
||||
"calendar.access.attributed_group": "group attributed",
|
||||
"calendar.access.attributed_user": "user attributed",
|
||||
"widget.listview.add": "add event",
|
||||
"widget.weekview.controls.year": "year",
|
||||
"widget.weekview.controls.week": "week",
|
||||
|
|
|
|||
|
|
@ -151,7 +151,42 @@ namespace _dali.helpers
|
|||
|
||||
/**
|
||||
*/
|
||||
export function input_attributed_access(
|
||||
export function input_attributed_access_group(
|
||||
groups : Array<{id : _dali.type_group_id; object : _dali.type_group_object;}>
|
||||
)
|
||||
: lib_plankton.zoo_input.class_input_hashmap<
|
||||
_dali.type_group_id,
|
||||
_dali.enum_access_level
|
||||
>
|
||||
{
|
||||
return (
|
||||
new lib_plankton.zoo_input.class_input_hashmap<_dali.type_group_id, _dali.enum_access_level>(
|
||||
// hash_key
|
||||
(group_id) => group_id.toFixed(0),
|
||||
// key_input_factory
|
||||
() => new lib_plankton.zoo_input.class_input_wrapped<string, int>(
|
||||
new lib_plankton.zoo_input.class_input_selection(
|
||||
groups
|
||||
.map(
|
||||
(group) => ({
|
||||
"value": group.id.toFixed(0),
|
||||
"label": group.object.label,
|
||||
})
|
||||
)
|
||||
),
|
||||
x => parseInt(x),
|
||||
x => x.toFixed(0)
|
||||
),
|
||||
// value_input_factory
|
||||
() => input_access_level()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function input_attributed_access_user(
|
||||
users : Array<{id : _dali.type_user_id; name : string;}>
|
||||
)
|
||||
: lib_plankton.zoo_input.class_input_hashmap<
|
||||
|
|
|
|||
101
source/model.ts
101
source/model.ts
|
|
@ -4,6 +4,12 @@ namespace _dali.model
|
|||
/**
|
||||
*/
|
||||
type type_state = {
|
||||
groups : Array<
|
||||
{
|
||||
id : _dali.type_group_id;
|
||||
object : _dali.type_group_object;
|
||||
}
|
||||
>;
|
||||
users : Array<
|
||||
{
|
||||
id : _dali.type_user_id;
|
||||
|
|
@ -110,6 +116,23 @@ namespace _dali.model
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function group_list(
|
||||
)
|
||||
: Promise<
|
||||
Array<
|
||||
{
|
||||
id : _dali.type_group_id;
|
||||
object : _dali.type_group_object;
|
||||
}
|
||||
>
|
||||
>
|
||||
{
|
||||
return Promise.resolve(_state.groups);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export async function user_list(
|
||||
|
|
@ -196,12 +219,30 @@ namespace _dali.model
|
|||
"access": {
|
||||
"public": data.access.public,
|
||||
"default_level": _dali.access_level_decode(data.access.default_level),
|
||||
"attributed": lib_plankton.map.hashmap.implementation_map(
|
||||
"attributed_group": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
data.access.attributed
|
||||
data.access.attributed_group
|
||||
.map(
|
||||
(entry) => (
|
||||
{
|
||||
"key": entry.group_id,
|
||||
"value": _dali.access_level_decode(entry.level),
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
}
|
||||
)
|
||||
),
|
||||
"attributed_user": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make(
|
||||
x => x.toFixed(0),
|
||||
{
|
||||
"pairs": (
|
||||
data.access.attributed_user
|
||||
.map(
|
||||
(entry) => (
|
||||
{
|
||||
|
|
@ -244,8 +285,19 @@ namespace _dali.model
|
|||
"access": {
|
||||
"public": calendar_object.access.public,
|
||||
"default_level": _dali.access_level_encode(calendar_object.access.default_level),
|
||||
"attributed": (
|
||||
lib_plankton.map.dump(calendar_object.access.attributed)
|
||||
"attributed_group": (
|
||||
lib_plankton.map.dump(calendar_object.access.attributed_group)
|
||||
.map(
|
||||
(pair) => (
|
||||
{
|
||||
"group_id": pair.key,
|
||||
"level": _dali.access_level_encode(pair.value),
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
"attributed_user": (
|
||||
lib_plankton.map.dump(calendar_object.access.attributed_user)
|
||||
.map(
|
||||
(pair) => (
|
||||
{
|
||||
|
|
@ -254,7 +306,7 @@ namespace _dali.model
|
|||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
},
|
||||
/**
|
||||
* @todo
|
||||
|
|
@ -298,15 +350,24 @@ namespace _dali.model
|
|||
"access": {
|
||||
"public": calendar_object.access.public,
|
||||
"default_level": _dali.access_level_encode(calendar_object.access.default_level),
|
||||
"attributed": (
|
||||
lib_plankton.map.dump(calendar_object.access.attributed)
|
||||
"attributed_group": (
|
||||
lib_plankton.map.dump(calendar_object.access.attributed_group)
|
||||
.map(
|
||||
(pair) => ({
|
||||
"group_id": pair.key,
|
||||
"level": _dali.access_level_encode(pair.value),
|
||||
})
|
||||
)
|
||||
),
|
||||
"attributed_user": (
|
||||
lib_plankton.map.dump(calendar_object.access.attributed_user)
|
||||
.map(
|
||||
(pair) => ({
|
||||
"user_id": pair.key,
|
||||
"level": _dali.access_level_encode(pair.value),
|
||||
})
|
||||
)
|
||||
)
|
||||
),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
@ -554,13 +615,8 @@ namespace _dali.model
|
|||
: Promise<void>
|
||||
{
|
||||
_state = {
|
||||
"users": (
|
||||
_dali.is_logged_in()
|
||||
?
|
||||
(await _dali.backend.user_list())
|
||||
:
|
||||
[]
|
||||
),
|
||||
"groups": [],
|
||||
"users": [],
|
||||
"calendars": lib_plankton.map.hashmap.implementation_map(
|
||||
lib_plankton.map.hashmap.make(
|
||||
calendar_id => calendar_id.toFixed(0)
|
||||
|
|
@ -577,6 +633,20 @@ namespace _dali.model
|
|||
|
||||
_dali.listen_login(
|
||||
async () => {
|
||||
_state.groups = (
|
||||
(await _dali.backend.group_list())
|
||||
.map(
|
||||
entry => (
|
||||
{
|
||||
"id": entry.id,
|
||||
"object": {
|
||||
"name": entry.name,
|
||||
"label": entry.label,
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
_state.users = await _dali.backend.user_list();
|
||||
await sync_calendars();
|
||||
lib_plankton.map.clear(_state.events);
|
||||
|
|
@ -586,6 +656,7 @@ namespace _dali.model
|
|||
);
|
||||
_dali.listen_logout(
|
||||
async () => {
|
||||
_state.groups = [];
|
||||
_state.users = [];
|
||||
await sync_calendars();
|
||||
lib_plankton.map.clear(_state.events);
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ namespace _dali.pages.overview
|
|||
: Promise<void>
|
||||
{
|
||||
const widget = new _dali.widgets.calendar_edit.class_widget_calendar_edit(
|
||||
await _dali.model.group_list(),
|
||||
await _dali.model.user_list(),
|
||||
{
|
||||
"name": "",
|
||||
|
|
@ -143,7 +144,18 @@ namespace _dali.pages.overview
|
|||
"access": {
|
||||
"public": false,
|
||||
"default_level": _dali.enum_access_level.view,
|
||||
"attributed": lib_plankton.map.hashmap.implementation_map<
|
||||
"attributed_group": lib_plankton.map.hashmap.implementation_map<
|
||||
_dali.type_group_id,
|
||||
_dali.enum_access_level
|
||||
>(
|
||||
lib_plankton.map.hashmap.make<
|
||||
_dali.type_group_id,
|
||||
_dali.enum_access_level
|
||||
>(
|
||||
group_id => group_id.toFixed(0),
|
||||
)
|
||||
),
|
||||
"attributed_user": lib_plankton.map.hashmap.implementation_map<
|
||||
_dali.type_user_id,
|
||||
_dali.enum_access_level
|
||||
>(
|
||||
|
|
@ -235,6 +247,7 @@ namespace _dali.pages.overview
|
|||
calendar_id
|
||||
);
|
||||
const widget = new _dali.widgets.calendar_edit.class_widget_calendar_edit(
|
||||
await _dali.model.group_list(),
|
||||
await _dali.model.user_list(),
|
||||
calendar_object,
|
||||
{
|
||||
|
|
@ -289,6 +302,12 @@ namespace _dali.pages.overview
|
|||
}
|
||||
)
|
||||
: Promise<void>
|
||||
{
|
||||
if (! _dali.is_logged_in())
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
const widget = new _dali.widgets.event_edit.class_widget_event_edit(
|
||||
(await get_available_calendars()),
|
||||
|
|
@ -360,6 +379,7 @@ namespace _dali.pages.overview
|
|||
_dali.overlay.toggle({"mode": true});
|
||||
await widget.load(_dali.overlay.get_content_element());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -411,6 +411,28 @@ namespace _dali.backend
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function group_list(
|
||||
)
|
||||
: Promise<
|
||||
Array<
|
||||
{
|
||||
id : int;
|
||||
name : string;
|
||||
label : string;
|
||||
}
|
||||
>
|
||||
>
|
||||
{
|
||||
return call(
|
||||
lib_plankton.http.enum_method.get,
|
||||
"/groups",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function user_list(
|
||||
|
|
@ -512,12 +534,18 @@ namespace _dali.backend
|
|||
access : {
|
||||
public : boolean;
|
||||
default_level : string;
|
||||
attributed : Array<
|
||||
attributed_group : Array<
|
||||
{
|
||||
group_id : int;
|
||||
level : string;
|
||||
}
|
||||
>;
|
||||
attributed_user : Array<
|
||||
{
|
||||
user_id : int;
|
||||
level : string;
|
||||
}
|
||||
>
|
||||
>;
|
||||
};
|
||||
resource_id : int;
|
||||
}
|
||||
|
|
@ -544,7 +572,13 @@ namespace _dali.backend
|
|||
access : {
|
||||
public : boolean;
|
||||
default_level : string;
|
||||
attributed : Array<
|
||||
attributed_group : Array<
|
||||
{
|
||||
group_id : int;
|
||||
level : string;
|
||||
}
|
||||
>;
|
||||
attributed_user : Array<
|
||||
{
|
||||
user_id : int;
|
||||
level : string;
|
||||
|
|
@ -595,7 +629,13 @@ namespace _dali.backend
|
|||
access : {
|
||||
public : boolean;
|
||||
default_level : string;
|
||||
attributed : Array<
|
||||
attributed_group : Array<
|
||||
{
|
||||
group_id : int;
|
||||
level : string;
|
||||
}
|
||||
>;
|
||||
attributed_user : Array<
|
||||
{
|
||||
user_id : int;
|
||||
level : string;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,19 @@ namespace _dali
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export type type_group_id = int;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export type type_group_object = {
|
||||
name : string;
|
||||
label : string;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export type type_user_id = int;
|
||||
|
|
@ -23,6 +36,7 @@ namespace _dali
|
|||
*/
|
||||
export type type_user_object = {
|
||||
name : string;
|
||||
label : string;
|
||||
email_address : (
|
||||
null
|
||||
|
|
||||
|
|
@ -137,7 +151,11 @@ namespace _dali
|
|||
access : {
|
||||
public : boolean;
|
||||
default_level : enum_access_level;
|
||||
attributed : lib_plankton.map.type_map<
|
||||
attributed_group : lib_plankton.map.type_map<
|
||||
type_group_id,
|
||||
enum_access_level
|
||||
>;
|
||||
attributed_user : lib_plankton.map.type_map<
|
||||
type_user_id,
|
||||
enum_access_level
|
||||
>;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ namespace _dali.widgets.calendar_edit
|
|||
implements lib_plankton.zoo_widget.interface_widget
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
private groups : Array<{id : _dali.type_group_id; object : _dali.type_group_object;}>;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
private users : Array<{id : _dali.type_user_id; name : string;}>;
|
||||
|
|
@ -45,6 +50,7 @@ namespace _dali.widgets.calendar_edit
|
|||
/**
|
||||
*/
|
||||
public constructor(
|
||||
groups : Array<{id : _dali.type_group_id; object : _dali.type_group_object;}>,
|
||||
users : Array<{id : _dali.type_user_id; name : string;}>,
|
||||
initial_value : _dali.type_calendar_object,
|
||||
{
|
||||
|
|
@ -67,6 +73,7 @@ namespace _dali.widgets.calendar_edit
|
|||
}
|
||||
)
|
||||
{
|
||||
this.groups = groups;
|
||||
this.users = users;
|
||||
this.initial_value = initial_value;
|
||||
this.read_only = read_only;
|
||||
|
|
@ -121,9 +128,14 @@ namespace _dali.widgets.calendar_edit
|
|||
"label": lib_plankton.translate.get("calendar.access.default_level"),
|
||||
},
|
||||
{
|
||||
"name": "attributed",
|
||||
"input": _dali.helpers.input_attributed_access(this.users),
|
||||
"label": lib_plankton.translate.get("calendar.access.attributed"),
|
||||
"name": "attributed_group",
|
||||
"input": _dali.helpers.input_attributed_access_group(this.groups),
|
||||
"label": lib_plankton.translate.get("calendar.access.attributed_group"),
|
||||
},
|
||||
{
|
||||
"name": "attributed_user",
|
||||
"input": _dali.helpers.input_attributed_access_user(this.users),
|
||||
"label": lib_plankton.translate.get("calendar.access.attributed_user"),
|
||||
},
|
||||
]
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in a new issue