Skip to content
Open
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
12 changes: 9 additions & 3 deletions Component/SchemaFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ public function prepareConfigs($schemaConfigs)
$haveDs = false;
foreach (array('dataStore', 'featureType') as $dsKey) {
if (\array_key_exists($dsKey, $schemaConfig)) {
$schemaConfig[$dsKey] = $storeConfigs[$schemaName];
$schemaConfig[$dsKey] = $storeConfigs[$schemaConfig[$dsKey]];
$haveDs = true;
}
}
if (!$haveDs) {
throw new ConfigurationErrorException("No dataStore / featureType in schema {$schemaName}");
}
if (!empty($schemaConfig['formItems'])) {
$schemaConfig['formItems'] = $this->formItemFilter->prepareItems($schemaConfig['formItems']);
$schemaConfig['formItems'] = $this->prepareFormItems($schemaConfig);
} else {
@trigger_error("WARNING: no formItems in schema {$schemaName}. Object detail view will not work", E_USER_DEPRECATED);
$schemaConfig['formItems'] = array();
Expand All @@ -86,6 +86,11 @@ public function prepareConfigs($schemaConfigs)
return $schemaConfigs;
}


protected function prepareFormItems($schemaConfig) {
return $this->formItemFilter->prepareItems($schemaConfig['formItems']);
}

/**
* @param Element $element
* @param string $schemaName
Expand Down Expand Up @@ -143,7 +148,8 @@ public function getDataStoreConfig(Element $element, $schemaName)
$elementConfig = $element->getConfiguration();
$schemaConfigs = $elementConfig['schemes'];
$storeConfigs = DataStoreUtil::configsFromSchemaConfigs($this->registry, $schemaConfigs);
return $storeConfigs[$schemaName];
$schemaConfig = $schemaConfigs[$schemaName];
return $storeConfigs[$schemaConfig["featureType"]];
}

/**
Expand Down
11 changes: 10 additions & 1 deletion Resources/public/FormRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@
}
}

Mapbender.DataManager.FormRenderer = function FormRenderer() {
Mapbender.DataManager.FormRenderer = function FormRenderer(owner,schemes) {
var schemaNames = Object.keys(schemes);
for (var s = 0; s < schemaNames.length; ++s) {
var schemaName = schemaNames[s];
var schema = schemes[schemaName];
var fileConfigs = owner._getDataStoreFromSchema(schema).files || [];
var schemaBaseUrl = [owner.elementUrl, schemaName, '/'].join('');
this.prepareItems(schema.formItems || [], schemaBaseUrl, fileConfigs);
}

};

Object.assign(Mapbender.DataManager.FormRenderer.prototype, {
Expand Down
19 changes: 9 additions & 10 deletions Resources/public/dataManager.element.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,13 @@
this.selector = $(this._renderSchemaSelector(this.element));
this.formRenderer_ = this._createFormRenderer();
this.dialogFactory_ = Mapbender.DataManager.DialogFactory;
var schemaNames = Object.keys(this.options.schemes);
for (var s = 0; s < schemaNames.length; ++s) {
var schemaName = schemaNames[s];
var schema = this.options.schemes[schemaName];
var fileConfigs = this._getDataStoreFromSchema(schema).files || [];
var schemaBaseUrl = [this.elementUrl, schemaName, '/'].join('');
this.formRenderer_.prepareItems(schema.formItems || [], schemaBaseUrl, fileConfigs);
}
this.tableRenderer = this._createTableRenderer();
this._initializeEvents();
this._afterCreate();
},

_createFormRenderer: function() {
return new Mapbender.DataManager.FormRenderer();
return new Mapbender.DataManager.FormRenderer(this, this.options.schemes);
},
_createTableRenderer: function() {
return new Mapbender.DataManager.TableRenderer(this);
Expand Down Expand Up @@ -105,15 +98,21 @@
this.hasOnlyOneScheme = (nSchemes === 1);
$container.append(selector);

let visibleSchemes = this._filterVisibleSchemes();

// build select options
_.each(this.options.schemes, function(schemaConfig) {
_.each(visibleSchemes, function(schemaConfig) {
var option = $("<option/>");
option.val(schemaConfig.schemaName).text(schemaConfig.label);
option.data('schema', schemaConfig);
selector.append(option);
});
return selector;
},

_filterVisibleSchemes: function() {
return this.options.schemes;
},
/**
* Unraveled from _create for child class actions after initialization, but
* before triggering ready event and loading the first set of data.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"doctrine/dbal": "^2.11 || ^3",
"doctrine/persistence": "^1.3.0 || ^2",
"blueimp/jquery-file-upload": "9.*",
"mapbender/data-source": "~0.1.24 || ^0.2",
"mapbender/data-source": "dev-feature/enableDBSIMMSupport",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert this change, relying on a feature branch of another repo from the main branch is not a good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, this has to be adapted in case of merging. I just need the feature branches like this for the moment, since I rely on these changes and that unfortunately includes the dependency. What would be the appropriate way of handling this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably releasing new versions of all packages at the same time. A composer update will then update all of the dependencies

"mapbender/mapbender": "^3.2.6"
},
"autoload": {
Expand Down