Skip to content

Commit

Permalink
Merge pull request #523 from jeff-phillips-18/parameters
Browse files Browse the repository at this point in the history
Add opaque keys option to catalog parameters component
  • Loading branch information
spadgett authored Oct 23, 2017
2 parents a22fd27 + 970b8aa commit f2b24b8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
9 changes: 6 additions & 3 deletions dist/origin-web-catalogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ webpackJsonp([ 0, 1 ], [ function(e, t) {
parameterFormDefinition: "<",
isHorizontal: "<?",
readOnly: "<?",
opaqueKeys: "<?",
hideValues: "<?",
model: "="
},
Expand Down Expand Up @@ -1125,13 +1126,15 @@ webpackJsonp([ 0, 1 ], [ function(e, t) {
e.enum = void 0, "array" !== e.type && "number" !== e.type && "integer" !== e.type && "boolean" !== e.type || (e.type = "string"));
}, e.prototype.updateValueToHidden = function(e) {
var t = this;
return n.isObject(e) || n.isArray(e) ? n.mapValues(e, function(e) {
return n.isObject(e) || n.isArray(e) ? n.mapValues(e, function(e, r) {
return n.includes(t.ctrl.opaqueKeys, r) ? e : t.updateValueToHidden(e);
}) : n.isArray(e) ? n.map(e, function(e) {
return t.updateValueToHidden(e);
}) : "*****";
}, e.prototype.updateHiddenModel = function() {
var e = this;
this.ctrl.hideValues && (this.ctrl.hiddenModel = n.mapValues(this.ctrl.model, function(t) {
return e.updateValueToHidden(t);
this.ctrl.hideValues && (this.ctrl.hiddenModel = n.mapValues(this.ctrl.model, function(t, r) {
return n.includes(e.ctrl.opaqueKeys, r) ? t : e.updateValueToHidden(t);
}));
}, e.prototype.cloneParameterForm = function(t) {
if (n.isString(t)) return !0 === this.ctrl.readOnly ? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const catalogParameters: angular.IComponentOptions = {
parameterFormDefinition: '<',
isHorizontal: '<?',
readOnly: '<?',
opaqueKeys: '<?',
hideValues: '<?',
model: '='
},
Expand Down
17 changes: 13 additions & 4 deletions src/components/catalog-parameters/catalog-parameters.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,16 @@ export class CatalogParametersController implements angular.IController {

private updateValueToHidden(value: any): any {
if (_.isObject(value) || _.isArray(value)) {
return _.mapValues(value, (subValue: any) => {
return _.mapValues(value, (subValue: any, key: any) => {
if (_.includes(this.ctrl.opaqueKeys, key)) {
return subValue;
}
return this.updateValueToHidden(subValue);
});
} else if (_.isArray(value)) {
return _.map(value, (indexValue: any) => {
return this.updateValueToHidden(indexValue);
});
} else {
return '*****';
}
Expand All @@ -123,11 +130,13 @@ export class CatalogParametersController implements angular.IController {
return;
}

// form passwords show length of the string (badness), use our own string to hide that fact
this.ctrl.hiddenModel = _.mapValues(this.ctrl.model, (value: any) => {
this.ctrl.hiddenModel = _.mapValues(this.ctrl.model, (value: any, key: any) => {
if (_.includes(this.ctrl.opaqueKeys, key)) {
return value;
}
return this.updateValueToHidden(value);
});
}
}

// clones a form definition with only the accepted keys (key, type, items)
// and type values (fieldset, text, textarea, password, checkbox, select)
Expand Down

0 comments on commit f2b24b8

Please sign in to comment.