Merge branch 'visual-console-refactor' of https://brutus.artica.lan:8081/artica/pandorafms into visual-console-refactor
Former-commit-id: fa8ca4926182324c3d1307ac651c475568c64cf6
This commit is contained in:
commit
2bd32a91dc
|
@ -324,10 +324,28 @@ final class Container extends Model
|
||||||
int $layoutId,
|
int $layoutId,
|
||||||
array $aclUserGroups=[]
|
array $aclUserGroups=[]
|
||||||
): array {
|
): array {
|
||||||
$filter = ['id_layout' => $layoutId];
|
|
||||||
// If is empty array user view all groups.
|
// If is empty array user view all groups.
|
||||||
if (count($aclUserGroups) > 0) {
|
if (count($aclUserGroups) > 0) {
|
||||||
$filter['element_group'] = $aclUserGroups;
|
// Filter group for elements groups.
|
||||||
|
$filterCondition = ['id_layout' => $layoutId];
|
||||||
|
$filterCondition['element_group'] = $aclUserGroups;
|
||||||
|
// Format filter mysql.
|
||||||
|
$filter[0] = db_format_array_where_clause_sql(
|
||||||
|
$filterCondition
|
||||||
|
);
|
||||||
|
|
||||||
|
// Filter groups for type groups.
|
||||||
|
// Only true condition if type is GROUP_ITEM.
|
||||||
|
$filterGroup = [];
|
||||||
|
$filterGroup['type'] = GROUP_ITEM;
|
||||||
|
$filterGroup['id_group'] = $aclUserGroups;
|
||||||
|
|
||||||
|
// Format filter mysql.
|
||||||
|
$filter[1] = '('.db_format_array_where_clause_sql(
|
||||||
|
$filterGroup
|
||||||
|
).')';
|
||||||
|
} else {
|
||||||
|
$filter = ['id_layout' => $layoutId];
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
|
@ -335,7 +353,12 @@ final class Container extends Model
|
||||||
'type',
|
'type',
|
||||||
];
|
];
|
||||||
|
|
||||||
$rows = \db_get_all_rows_filter('tlayout_data', $filter, $fields);
|
$rows = \db_get_all_rows_filter(
|
||||||
|
'tlayout_data',
|
||||||
|
$filter,
|
||||||
|
$fields,
|
||||||
|
'OR'
|
||||||
|
);
|
||||||
|
|
||||||
if ($rows === false) {
|
if ($rows === false) {
|
||||||
$rows = [];
|
$rows = [];
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { LinkedVisualConsoleProps, UnknownObject } from "../types";
|
import { LinkedVisualConsoleProps, UnknownObject } from "../types";
|
||||||
import { linkedVCPropsDecoder, parseIntOr } from "../lib";
|
import { linkedVCPropsDecoder, parseIntOr, notEmptyStringOr } from "../lib";
|
||||||
import Item, { ItemProps, itemBasePropsDecoder, ItemType } from "../Item";
|
import Item, { ItemProps, itemBasePropsDecoder, ItemType } from "../Item";
|
||||||
|
|
||||||
export type GroupProps = {
|
export type GroupProps = {
|
||||||
type: ItemType.GROUP_ITEM;
|
type: ItemType.GROUP_ITEM;
|
||||||
imageSrc: string; // URL?
|
imageSrc: string; // URL?
|
||||||
groupId: number;
|
groupId: number;
|
||||||
|
statusImageSrc: string | null;
|
||||||
} & ItemProps &
|
} & ItemProps &
|
||||||
LinkedVisualConsoleProps;
|
LinkedVisualConsoleProps;
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ export function groupPropsDecoder(data: UnknownObject): GroupProps | never {
|
||||||
type: ItemType.GROUP_ITEM,
|
type: ItemType.GROUP_ITEM,
|
||||||
imageSrc: data.imageSrc,
|
imageSrc: data.imageSrc,
|
||||||
groupId: parseInt(data.groupId),
|
groupId: parseInt(data.groupId),
|
||||||
|
statusImageSrc: notEmptyStringOr(data.statusImageSrc, null),
|
||||||
...linkedVCPropsDecoder(data) // Object spread. It will merge the properties of the two objects.
|
...linkedVCPropsDecoder(data) // Object spread. It will merge the properties of the two objects.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -39,7 +41,9 @@ export default class Group extends Item<GroupProps> {
|
||||||
protected createDomElement(): HTMLElement {
|
protected createDomElement(): HTMLElement {
|
||||||
const img: HTMLImageElement = document.createElement("img");
|
const img: HTMLImageElement = document.createElement("img");
|
||||||
img.className = "group";
|
img.className = "group";
|
||||||
img.src = this.props.imageSrc;
|
if (this.props.statusImageSrc != null) {
|
||||||
|
img.src = this.props.statusImageSrc;
|
||||||
|
}
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue