Skip to content

Commit

Permalink
Merge pull request #710 from Orckestra/dev
Browse files Browse the repository at this point in the history
TreeSelector has support for selecting EntityTokens, more guidance on parametter setting
  • Loading branch information
mawtex authored Nov 28, 2019
2 parents e40b0ff + cc0a3df commit f8fdb5b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ public Control BuildWebControl()

_userControl.SelectedKey = this.SelectedKey;
_userControl.ElementProvider = this.ElementProvider;
_userControl.SelectableElementPropertyName = this.SelectableElementPropertyName;
_userControl.SelectableElementPropertyValue = this.SelectableElementPropertyValue;
_userControl.SelectableElementReturnValue = this.SelectableElementReturnValue;
_userControl.SelectableElementPropertyName = string.IsNullOrEmpty(this.SelectableElementPropertyName) ? this.SelectableElementReturnValue : this.SelectableElementPropertyName;
_userControl.SelectableElementPropertyValue = this.SelectableElementPropertyValue;
_userControl.SerializedSearchToken = this.SerializedSearchToken;
_userControl.Required = this.Required;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,39 +35,40 @@ private void SetParameterProfiles()
"Element Provider", new HelpDefinition("The name of a tree element provider (as defined in Composite.config)")));

base.AddParameterProfile(
new ParameterProfile("SelectableElementPropertyName",
new ParameterProfile("SelectableElementReturnValue",
typeof(string),
true,
new ConstantValueProvider(string.Empty),
new ConstantValueProvider("EntityToken"),
StandardWidgetFunctions.TextBoxWidget,
null,
"Selectable Element Property Name", new HelpDefinition("The name of a property used to identify a selectable tree element by")));
"Element field to return", new HelpDefinition("The name of the element field whose value to return for selection. Typical values here can be DataId (for data trees), Uri (for linkable elements), or EntityToken (for any element). Element providers may provide more fields.")));

base.AddParameterProfile(
new ParameterProfile("SelectableElementPropertyValue",
new ParameterProfile("SelectableElementPropertyName",
typeof(string),
false,
new ConstantValueProvider(string.Empty),
StandardWidgetFunctions.TextBoxWidget,
null,
"Selectable Element Property Value", new HelpDefinition("The value of the property optionally used (if provided) to further identify a selectable tree element by")));
"Selection filter, Property Name", new HelpDefinition("An element must have this field to be selectable.")));

base.AddParameterProfile(
new ParameterProfile("SelectableElementReturnValue",
new ParameterProfile("SelectableElementPropertyValue",
typeof(string),
false,
new ConstantValueProvider(string.Empty),
StandardWidgetFunctions.TextBoxWidget,
null,
"Selectable Element Return Value", new HelpDefinition("The value to return for the selected tree element")));
"Selection filter, Property Value", new HelpDefinition("The value of the property optionally used (if provided) to further identify a selectable tree element by. Seperate multiple values with spaces.")));

base.AddParameterProfile(
new ParameterProfile("SerializedSearchToken",
typeof(string),
false,
new ConstantValueProvider(string.Empty),
StandardWidgetFunctions.TextBoxWidget,
null,
"Selectable Element Return Value", new HelpDefinition("A search token to filter tree elements by")));
"Search Token", new HelpDefinition("A search token, seriallized, to filter which tree elements is shown. To filter what is selectable, use the 'Selection filter' properties.")));
base.AddParameterProfile(
new ParameterProfile("Required",
typeof(bool),
Expand All @@ -85,7 +86,7 @@ public override XElement GetWidgetMarkup(ParameterList parameters, string label,
XElement formElement = base.BuildBasicWidgetMarkup("TreeSelector", "SelectedKey", label, helpDefinition, bindingSourceName);
foreach (var propertyName in new []
{
"ElementProvider", "SelectableElementPropertyName", "SelectableElementPropertyValue", "SelectableElementReturnValue", "SerializedSearchToken", "Required"
"ElementProvider", "SelectableElementReturnValue", "SelectableElementPropertyName", "SelectableElementPropertyValue", "SerializedSearchToken", "Required"
})
{
string propertyValue = parameters.GetParameter<string>(propertyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,16 +601,9 @@ TreeSelectorDialogPageBinding.prototype._updateDisplayAndResult = function (tree
var prop = this._selectionResult;

selections.each ( function ( binding ) {
if (prop == "EntityToken" && binding.node) {

result.add(
binding.node.getEntityToken()
);
} else {
result.add(
binding.getProperty(prop)
);
}
result.add(
binding.getProperty(prop)
);
value += binding.getLabel ();
if ( selections.hasNext ()) {
value += "; ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,19 @@ SystemTreeNodeBinding.prototype.selectToken = function (entityToken) {
this.setHandle(this.node.getHandle());
}

/**
* Get bound element attribute or EnityToken.
* @overloads {Binding#getProperty}
*/
SystemTreeNodeBinding.prototype.getProperty = function ( attname ) {

if(attname == 'EntityToken' && this.node && this.node.getEntityToken()) {
return this.node.getEntityToken();
}

return SystemTreeNodeBinding.superclass.getProperty.call ( this, attname );
}

/**
* SystemTreeNodeBinding factory. Notice that we supply a {@link SystemNode} as argument here!
* @param {SystemNode} node
Expand Down

0 comments on commit f8fdb5b

Please sign in to comment.