From 90a6dd255711b25926f820bfbd0c2d7aa8dba29a Mon Sep 17 00:00:00 2001 From: Vincent Fiduccia Date: Tue, 24 Mar 2015 17:12:07 -0700 Subject: [PATCH] Support arrays of embedded types --- package.json | 5 +++-- scripts/upload | 4 ++-- src/HTMLApi.js | 23 +++++++++++------------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 6b2c73d..120a695 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "api-ui", - "version": "1.0.3", + "version": "1.0.4", "description": "Embedded UI for any service that implements the Rancher API spec", "contributors": [ "Go Daddy Operating Company, LLC. (http://godaddy.com)", @@ -16,7 +16,8 @@ "scripts": { "start": "./node_modules/.bin/gulp server", "clean": "./node_modules/.bin/gulp clean", - "build": "./node_modules/.bin/gulp build" + "build": "./node_modules/.bin/gulp build", + "upload": "./scripts/upload" }, "devDependencies": { "del": "^1.1.0", diff --git a/scripts/upload b/scripts/upload index 482f1bf..99f7597 100755 --- a/scripts/upload +++ b/scripts/upload @@ -19,7 +19,7 @@ function exec() { VERSION=$(cat package.json | grep version | cut -f4 -d'"' | sed 's/-/_/g') BUILD_DIR="dist/${VERSION}" -CDN="cdn.rancher.io/api-ui" +CDN="releases.rancher.com/api-ui" echo "Uploading..." -exec gsutil -m cp -R $BUILD_DIR "gs://${CDN}/" +exec gsutil -m cp -R -z "js,css,map" $BUILD_DIR "gs://${CDN}/" diff --git a/src/HTMLApi.js b/src/HTMLApi.js index 4200b4e..aad9870 100644 --- a/src/HTMLApi.js +++ b/src/HTMLApi.js @@ -1437,7 +1437,7 @@ HTMLApi.prototype._flattenField = function(mode, name, field, data, depth) var displayType = field._typeList[ field._typeList.length - 1]; var parentType = field._typeList[ field._typeList.length - 2]; - if ( isEmbedded || (parentType && parentType == 'reference') ) + if ( isEmbedded || (parentType && (parentType == 'reference' || parentType == 'array' || parentType == 'map')) ) { var link = null; if ( field.referenceCollection ) @@ -1576,6 +1576,16 @@ HTMLApi.prototype._flattenInputs = function($form) isMapValue = k.indexOf('.value{}') >= 0; isJsonValue = k.indexOf('.json{}') >= 0; + name = k; + if ( isJsonValue ) + name = name.replace(/\.json\{\}$/,''); + if ( isMapKey ) + name = name.replace(/\.key\{\}$/,''); + if ( isMapValue ) + name = name.replace(/\.value\{\}$/,''); + if ( isArray ) + name = name.replace(/\[\]$/,''); + if ( isJsonValue ) { try { @@ -1589,7 +1599,6 @@ HTMLApi.prototype._flattenInputs = function($form) if ( isArray ) { - name = k.replace(/\[\]$/,''); if ( typeof inputs[name] === "undefined" ) inputs[name] = []; @@ -1597,14 +1606,6 @@ HTMLApi.prototype._flattenInputs = function($form) } else if ( isMapKey || isMapValue ) { - name = k; - if ( isJsonValue ) - name = name.replace(/\.json\{\}$/,''); - if ( isMapKey ) - name = name.replace(/\.key\{\}$/,''); - else if ( isMapValue ) - name = name.replace(/\.value\{\}$/,''); - if ( typeof maps[name] === 'undefined' ) { maps[name] = {keys: [], values: []}; @@ -1617,8 +1618,6 @@ HTMLApi.prototype._flattenInputs = function($form) } else if ( isJsonValue ) { - name = k; - name = name.replace(/\.json\{\}$/,''); inputs[name] = v; } else