Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/document-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ exports.DocumentResources = class DocumentResources extends Montage {
const classListScope = cssContext.classListScope;
const cssLayerName = cssContext.cssLayerName;
const stylesheet = target.sheet;
const cssRules = stylesheet.cssRules;
let cssRules;
try {
cssRules = stylesheet.cssRules;
} catch (e) {
cssRules = [];
}

/**
* Adding CSS Layers, and Scoping for components in dev mode.
Expand Down
30 changes: 30 additions & 0 deletions data/model/inspectors/organization.mod/organization.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

.OrganizationInspector {
height: 100%;



.field {
height: 100%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
align-items: start;
background: white;
}
.roleListItem {
border: 1px solid #eeeeee;
align-content: center;
padding: 12px 8px;
}
.roleListItem.selected {
background: #d9d9d9;
}
.roleList {
width: 100%;
height: 100%;
}

}


49 changes: 49 additions & 0 deletions data/model/inspectors/organization.mod/organization.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="organization.css">
<script type="text/mod-serialization">
{
"owner": {
"values": {
"element": {"#": "owner"},
"roleSelection": {"<-": "@roleList.selection"}
}
},
"roleList": {
"prototype": "../../../../ui/repetition.mod",
"values": {
"element": {"#": "roleList"},
"contentController": {"@": "roleListController"},
"isSelectionEnabled": true
}
},
"roleListController": {
"prototype": "../../../../core/range-controller",
"values": {
"content": {"<-": "@owner.data.suborganizations.map{jobRoles}.flatten()"}
}
},
"roleListItem": {
"prototype": "../../../../ui/text.mod",
"values": {
"element": {"#": "roleListItem"},
"value": {"<-": "@roleList:iteration.object.name"},
"object": {"<-": "@roleList:iteration.object"}
}
}
}
</script>
</head>
<body>
<div data-mod-id="owner" class="OrganizationInspector">
<div class="field">
<div class="roleList" data-mod-id="roleList">
<div class="roleListItem">
<div data-mod-id="roleListItem" class="roleListItemName"></div>
</div>
</div>
</div>
</div>
</body>
</html>
63 changes: 63 additions & 0 deletions data/model/inspectors/organization.mod/organization.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
var Component = require("../../../../ui/component").Component;

const DataService = require("../../../../data/service/data-service").DataService;


exports.Organization = class Organization extends Component {

context = null;

getContext() {
const grandparent = this.parentComponent && this.parentComponent.parentComponent;
return grandparent && grandparent.context;
}

_roleSelection;

get roleSelection() {
return this._roleSelection;
}

set roleSelection(value) {
if (this._roleSelection !== value) {
this._roleSelection = value;
}
}

enterDocument(firstTime) {
if (firstTime) {
if (!this.data){
throw new Error("Department context is required for Organization inspector");
}
this.#buildJobRolesFromDepartment(this.data).then((roles) => {
this.roles = roles;
});
this.context = this.getContext();
this.addRangeAtPathChangeListener("roleSelection", this, "_handleSelectionChange");
}
}

_handleSelectionChange(plus, minus, index) {
var obj = {plus: plus, context: this.context};
this.dispatchEventNamed("cascadingListPush", true, false, obj);
}

#buildJobRolesFromDepartment(department) {
return DataService.mainService
.updateObjectProperties(department, "suborganizations")
.then(() => {
return Promise.all(
department.suborganizations.map((suborg) => {
return DataService.mainService.updateObjectProperties(suborg, "jobRoles").then(() => {
return suborg.jobRoles;
});
})
);
})
.then((results) => {
return results.flat();
});
// const { suborganizations = [] } = department;
// return suborganizations.flatMap((suborg) => suborg.jobRoles || []);
}
};
10 changes: 10 additions & 0 deletions data/model/party/organization-cascading-list-ui-descriptor.mjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"root": {
"prototype": "core/meta/user-interface-descriptor",
"values": {
"cascadingListItemHeaderRightCollectionNameExpression": "",
"cascadingListItemHeaderRightNameExpression": "'Add'",
"cascadingListItemFooterMiddleCollectionNameExpression": "length + ' item' + (length == 1 ? '' : 's')"
}
}
}
3 changes: 3 additions & 0 deletions data/model/party/organization-ui-descriptor.mjson
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"root": {
"prototype": "core/meta/user-interface-descriptor",
"values": {
"inspectorComponentModule": {
"%": "data/model/inspectors/organization.mod"
},
"collectionNameExpression": "'Organization'",
"collectionInspectorComponentModule": {
"%": "ui/list.mod"
Expand Down
3 changes: 3 additions & 0 deletions data/model/party/organization.mjson
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"userInterfaceDescriptorModules": {
"*": {
"%": "./organization-ui-descriptor.mjson"
},
"mod/ui/cascading-list.mod": {
"%": "./organization-cascading-list-ui-descriptor.mjson"
}
}

Expand Down
2 changes: 1 addition & 1 deletion ui/action-target.mod/action-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var Component = require("../component").Component,
* @extends Control
*/
var ActionTarget = exports.ActionTarget = Control.specialize( /** @lends ActionTarget.prototype # */ {

hasTemplate: {
value: false
},
Expand Down
10 changes: 10 additions & 0 deletions ui/cascading-list.mod/cascading-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ CascadingList.addClassProperties( {
if (!this._populatePromise && object) {
var self = this;

if(Array.isArray(object)){
//TODO:
//1) Find the highest common ancestor with existing object descriptor among all instances in the array
//2) Grab UI descriptor for that ancestor
}
else{
//TODO:
//1) Refactor below to be used in both cases once UI descriptor is obtained

}
this._populatePromise = this.loadUserInterfaceDescriptor(object).then(function (UIDescriptor) {
var context = self._createCascadingListContextWithObjectAndColumnIndex(
object,
Expand Down