diff --git a/app/controllers/config.controller.js b/app/controllers/config.controller.js index d367b9a..da2a26b 100644 --- a/app/controllers/config.controller.js +++ b/app/controllers/config.controller.js @@ -4,7 +4,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio var newPropertyModel = '{alias: "", remove: false, label: "", helpText: "", view: "", value: "", config: {}}'; var newFieldsetModel = '{alias: "", remove: false, collapse: false, tooltip: "", icon: "", label: "", headerText: "", footerText: "", properties:[' + newPropertyModel + ']}'; - var defaultFieldsetConfigModel = eval("({fieldsets: [" + newFieldsetModel + "]})"); + var defaultFieldsetConfigModel = eval("({showAdvancedOptions: false, hideFieldsetToolbar: false, hideFieldsetControls: false, hideFieldsetLabels: false, hidePropertyLabel: false, maxFieldsets:1, fieldsets: [" + newFieldsetModel + "]})"); $scope.model.value = $scope.model.value || defaultFieldsetConfigModel; diff --git a/app/controllers/controller.js b/app/controllers/controller.js index b62cb21..5b823fd 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -1,30 +1,24 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($scope, $http, assetsService) { //$scope.model.value = ""; - //set default value of the model //this works by checking to see if there is a model; then cascades to the default model then to an empty fieldset - //validate the user configs - $scope.model.config.defaultModel = getValidJson("$scope.model.config.defaultModel", $scope.model.config.defaultModel); - $scope.model.config.fieldsetModels = $scope.model.config.archetypeConfig; + $scope.model.config = $scope.model.config.archetypeConfig; - console.log($scope.model.config.archetypeConfig); - - $scope.model.value = $scope.model.value || ($scope.model.config.defaultModel || { fieldsets: [getEmptyRenderItem($scope.model.config.fieldsetModels[0])] }); + $scope.model.value = $scope.model.value || { fieldsets: [getEmptyRenderItem($scope.model.config.fieldsets[0])] }; //ini $scope.archetypeRenderModel = {}; initArchetypeRenderModel(); + console.log($scope.archetypeRenderModel); /* add/remove/sort */ //defines the options for the jquery sortable //i used an ng-model="archetypeRenderModel" so the sort updates the right model - //configuration overrides the default - var configSortableOptions = getValidJson("$scope.model.config.sortableOptions", $scope.model.config.sortableOptions); - $scope.sortableOptions = configSortableOptions || { + $scope.sortableOptions = { axis: 'y', cursor: "move", handle: ".handle", @@ -40,7 +34,7 @@ $scope.addRow = function (fieldsetAlias, $index) { if ($scope.canAdd()) { - if ($scope.model.config.fieldsetModels) + if ($scope.model.config.fieldsets) { var newRenderItem = getEmptyRenderItem($scope.getConfigFieldsetByAlias(fieldsetAlias)); @@ -68,9 +62,9 @@ //helpers for determining if a user can do something $scope.canAdd = function () { - if ($scope.model.config.maxProperties) + if ($scope.model.config.maxFieldsets) { - return countVisible() < $scope.model.config.maxProperties; + return countVisible() < $scope.model.config.maxFieldsets; } return true; @@ -91,16 +85,42 @@ //helper, ini the render model from the server (model.value) function initArchetypeRenderModel() { $scope.archetypeRenderModel = $scope.model.value; + + for(var i in $scope.archetypeRenderModel.fieldsets) + { + $scope.archetypeRenderModel.fieldsets[i].remove = false; + $scope.archetypeRenderModel.fieldsets[i].collapse = true; + } } //helper to get the correct fieldset from config $scope.getConfigFieldsetByAlias = function(alias) { - for (var i in $scope.model.config.fieldsetModels) { - if ($scope.model.config.fieldsetModels[i].alias == alias) { - return $scope.model.config.fieldsetModels[i]; + for (var i in $scope.model.config.fieldsets) { + if ($scope.model.config.fieldsets[i].alias == alias) { + return $scope.model.config.fieldsets[i]; } } } + + //helper for collapsing + $scope.focusFieldset = function(fieldset){ + var iniState; + + if(fieldset) + { + iniState = fieldset.collapse; + } + + for(var i in $scope.archetypeRenderModel.fieldsets) + { + $scope.archetypeRenderModel.fieldsets[i].collapse = true; + } + + if(iniState) + { + fieldset.collapse = !iniState; + } + } //helper returns valid JS or null function getValidJson(variable, json) @@ -157,9 +177,10 @@ for (var i in $scope.archetypeRenderModel.fieldsets) { if (!$scope.archetypeRenderModel.fieldsets[i].remove) { - //remove the 'remove' property as this is only for sorting/internal use - delete $scope.archetypeRenderModel.fieldsets[i].remove; - $scope.model.value.fieldsets.push($scope.archetypeRenderModel.fieldsets[i]); + //clone + var tempFieldset = JSON.parse(JSON.stringify( $scope.archetypeRenderModel.fieldsets[i])); + delete tempFieldset.remove; + $scope.model.value.fieldsets.push(tempFieldset); } } } diff --git a/app/directives/archetypeproperty.js b/app/directives/archetypeproperty.js index 632a675..7224ccc 100644 --- a/app/directives/archetypeproperty.js +++ b/app/directives/archetypeproperty.js @@ -1,12 +1,12 @@ angular.module("umbraco").directive('archetypeProperty', function ($compile, $http) { - function getFieldsetByAlias(fieldsetModels, alias) + function getFieldsetByAlias(fieldsets, alias) { - for (var i in fieldsetModels) + for (var i in fieldsets) { - if (fieldsetModels[i].alias == alias) + if (fieldsets[i].alias == alias) { - return fieldsetModels[i]; + return fieldsets[i]; } } } @@ -23,7 +23,7 @@ var linker = function (scope, element, attrs) { - var configFieldsetModel = getFieldsetByAlias(scope.archetypeConfig.fieldsetModels, scope.fieldset.alias); + var configFieldsetModel = getFieldsetByAlias(scope.archetypeConfig.fieldsets, scope.fieldset.alias); var view = configFieldsetModel.properties[scope.propertyConfigIndex].view; var label = configFieldsetModel.properties[scope.propertyConfigIndex].label; diff --git a/app/less/archetype.less b/app/less/archetype.less index 94deae2..cd1ccac 100644 --- a/app/less/archetype.less +++ b/app/less/archetype.less @@ -105,7 +105,8 @@ } .archetypeConfig .archetypeDeveloperModel { - width: 98%; + width: 88%; + margin-left: 30px; height: 100px; } @@ -132,10 +133,32 @@ margin-bottom: 0; } +.archetypeConfig .archetypeFieldsets { + margin-left: 0; +} + .archetypeConfig .archetypeFieldsetTitle { overflow: hidden; } .archetypeConfig .arechetypeCollapser{ margin-top: 10px; +} + +.archetypeConfig .archetypeOptions label{ + width: 200px; +} + +.archetypeConfig .archetypeAdvancedOptions label{ + width: 400px; +} + +.archetypeConfig .archetypeDeveloperModel { + margin-bottom: 10px; +} + +.archetypeConfig .archetypeMaxFieldsets{ + border: 1px solid #ddd; + width: 25px; + text-align: right; } \ No newline at end of file diff --git a/app/package.manifest b/app/package.manifest index 520496b..bfa5399 100644 --- a/app/package.manifest +++ b/app/package.manifest @@ -19,105 +19,6 @@ type: "Required" } ] - }, - { - label: "Hide fieldset toolbar?", - description: "Hides the fieldset toolbar that appears when more than one fieldset model appears.", - key: "hideFieldsetToolbar", - view: "boolean", - validation: [ - - ] - }, - { - label: "Hide fieldset editor controls?", - description: "Hides the fieldset add/remove/sort controls.", - key: "hideFieldsetControls", - view: "boolean", - validation: [ - - ] - }, - { - label: "Hide fieldset labels?", - description: "Hides the fieldset labels.", - key: "hideFieldsetLabels", - view: "boolean", - validation: [ - - ] - }, - { - label: "Hide property labels?", - description: "Hides the property labels.", - key: "hidePropertyLabels", - view: "boolean", - validation: [ - - ] - }, - { - label: "Default Model", - description: "(Optional) What would you the default model to be? Otherwise the model will defer to the Empty Fieldset Model for new items.", - key: "defaultModel", - view: "textarea", - validation: [ - - ] - }, - { - label: "Max Fieldsets", - description: "(Optional) How many Fieldsets are allowed? Entering '1' will disable the controls. Default is unlimited.", - key: "maxProperties", - view: "number", - validation: [ - - ] - }, - { - label: "Custom Wrapper Class", - description: "(Optional) Enter a custom CSS class that will be applied to the wrapper div.", - key: "customCssClass", - view: "textstring", - validation: [ - - ] - }, - { - label: "CSS File", - description: "(Optional) Enter a path for a custom CSS file to be included on the page.", - key: "customCssPath", - view: "textstring", - validation: [ - - ] - }, - { - label: "JS File", - description: "(Optional) Enter a path for a custom JS file to be included on the page.", - key: "customJsPath", - view: "textstring", - validation: [ - - ] - }, - { - label: "Developer Mode", - description: "(Advanced) Turn on for developer options.", - key: "developerMode", - view: "boolean", - validation: [ - - ] - }, - { - label: "Sortable Options", - description: "(Advanced) Override the default sortable controls with a JSON object.", - key: "sortableOptions", - view: "textarea", - validation: [ - - ] } ] } diff --git a/app/views/archetype.config.html b/app/views/archetype.config.html index 0675bb4..7ab6cae 100644 --- a/app/views/archetype.config.html +++ b/app/views/archetype.config.html @@ -1,5 +1,5 @@
-
diff --git a/app/views/archetype.html b/app/views/archetype.html index 84c7bb6..5b599df 100644 --- a/app/views/archetype.html +++ b/app/views/archetype.html @@ -1,8 +1,8 @@ 
-
+
    -
  • +
  • {{fieldsetModel.label}}
  • @@ -10,32 +10,34 @@