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:
Alejandro Gallardo Escobar 2019-04-15 17:01:01 +02:00
commit 2bd32a91dc
2 changed files with 32 additions and 5 deletions

View File

@ -324,10 +324,28 @@ final class Container extends Model
int $layoutId,
array $aclUserGroups=[]
): array {
$filter = ['id_layout' => $layoutId];
// If is empty array user view all groups.
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 = [
@ -335,7 +353,12 @@ final class Container extends Model
'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) {
$rows = [];

View File

@ -1,11 +1,12 @@
import { LinkedVisualConsoleProps, UnknownObject } from "../types";
import { linkedVCPropsDecoder, parseIntOr } from "../lib";
import { linkedVCPropsDecoder, parseIntOr, notEmptyStringOr } from "../lib";
import Item, { ItemProps, itemBasePropsDecoder, ItemType } from "../Item";
export type GroupProps = {
type: ItemType.GROUP_ITEM;
imageSrc: string; // URL?
groupId: number;
statusImageSrc: string | null;
} & ItemProps &
LinkedVisualConsoleProps;
@ -31,6 +32,7 @@ export function groupPropsDecoder(data: UnknownObject): GroupProps | never {
type: ItemType.GROUP_ITEM,
imageSrc: data.imageSrc,
groupId: parseInt(data.groupId),
statusImageSrc: notEmptyStringOr(data.statusImageSrc, null),
...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 {
const img: HTMLImageElement = document.createElement("img");
img.className = "group";
img.src = this.props.imageSrc;
if (this.props.statusImageSrc != null) {
img.src = this.props.statusImageSrc;
}
return img;
}