Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select datatype - Columnlength #2086

Merged
merged 5 commits into from Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions pimcore/models/Asset/Listing/Dao.php
Expand Up @@ -111,6 +111,8 @@ public function getTotalCount()
$select = $this->getQuery([new Expression('COUNT(*)')]);
$select->reset(QueryBuilder::LIMIT_COUNT);
$select->reset(QueryBuilder::LIMIT_OFFSET);
$select->reset(QueryBuilder::ORDER);
Copy link
Contributor

Choose a reason for hiding this comment

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

how is this related to the whole task ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was just a test if you review the code :p.

The line is not really related to this Pull request. I think i had just selected the this branch when i committed the issue - sorry .
Anyway - this should be merged in the core too.


$amount = (int) $this->db->fetchOne($select, $this->model->getConditionVariables());

return $amount;
Expand Down
49 changes: 47 additions & 2 deletions pimcore/models/DataObject/ClassDefinition/Data/Select.php
Expand Up @@ -60,14 +60,21 @@ class Select extends Model\DataObject\ClassDefinition\Data
*
* @var string
*/
public $queryColumnType = 'varchar(190)';
public $queryColumnType = 'varchar';

/**
* Type for the column
*
* @var string
*/
public $columnType = 'varchar(190)';
public $columnType = 'varchar';

/**
* Column length
*
* @var integer
*/
public $columnLength = 190;

/**
* Type for the generated phpdoc
Expand All @@ -76,6 +83,43 @@ class Select extends Model\DataObject\ClassDefinition\Data
*/
public $phpdocType = 'string';

/**
* @return integer
*/
public function getColumnLength()
{
return $this->columnLength;
}

/**
* @param $columnLength
* @return $this
*/
public function setColumnLength($columnLength)
{
if ($columnLength) {
$this->columnLength = $columnLength;
}

return $this;
}

/**
* @return string
*/
public function getColumnType()
{
return $this->columnType . "(" . $this->getColumnLength() . ")";
}

/**
* @return string
*/
public function getQueryColumnType()
{
return $this->queryColumnType . "(" . $this->getColumnLength() . ")";
}

/**
* @return array
*/
Expand Down Expand Up @@ -276,6 +320,7 @@ public function isEmpty($data)
public function synchronizeWithMasterDefinition(DataObject\ClassDefinition\Data $masterDefinition)
{
$this->options = $masterDefinition->options;
$this->columnLength = $masterDefinition->columnLength;
$this->defaultValue = $masterDefinition->defaultValue;
$this->optionsProviderClass = $masterDefinition->optionsProviderClass;
$this->optionsProviderData = $masterDefinition->optionsProviderData;
Expand Down
22 changes: 12 additions & 10 deletions pimcore/tests/_support/Resources/objects/class-import.json
Expand Up @@ -641,8 +641,9 @@
],
"width":"",
"defaultValue":null,
"queryColumnType":"varchar(255)",
"columnType":"varchar(255)",
"queryColumnType":"varchar",
"columnType":"varchar",
"columnLength": 190,
"phpdocType":"string",
"name":"select",
"title":"Select",
Expand Down Expand Up @@ -1719,8 +1720,8 @@
],
"width":"",
"defaultValue":null,
"queryColumnType":"varchar(255)",
"columnType":"varchar(255)",
"queryColumnType":"varchar",
"columnType":"varchar",
"phpdocType":"string",
"name":"country",
"title":"Country",
Expand Down Expand Up @@ -2842,8 +2843,8 @@
],
"width":"",
"defaultValue":null,
"queryColumnType":"varchar(255)",
"columnType":"varchar(255)",
"queryColumnType":"varchar",
"columnType":"varchar",
"phpdocType":"string",
"name":"languagex",
"title":"Language",
Expand Down Expand Up @@ -5868,8 +5869,8 @@
],
"width":"",
"defaultValue":null,
"queryColumnType":"varchar(255)",
"columnType":"varchar(255)",
"queryColumnType":"varchar",
"columnType":"varchar",
"phpdocType":"string",
"name":"user",
"title":"user2",
Expand Down Expand Up @@ -6378,8 +6379,9 @@
],
"width":"",
"defaultValue":null,
"queryColumnType":"varchar(255)",
"columnType":"varchar(255)",
"queryColumnType":"varchar",
"columnType":"varchar",
"columnLength": 190,
"phpdocType":"string",
"name":"lselect",
"title":"localized select",
Expand Down
19 changes: 19 additions & 0 deletions update-scripts/138/postupdate.php
@@ -0,0 +1,19 @@
<?php

$classList = new \Pimcore\Model\DataObject\ClassDefinition\Listing();
$classes = $classList->load();
if(is_array($classes)){
foreach($classes as $class){
$doSave = false;
foreach ($class->getFieldDefinitions() as $fieldDef) {
if($fieldDef instanceof \Pimcore\Model\DataObject\ClassDefinition\Data\Select) {
$fieldDef->setQueryColumnType("varchar");
$fieldDef->setColumnType("varchar");
$doSave = true;
}
}
if($doSave){
$class->save();
}
}
}
73 changes: 45 additions & 28 deletions web/pimcore/static6/js/pimcore/object/classes/data/select.js
Expand Up @@ -216,35 +216,52 @@ pimcore.object.classes.data.select = Class.create(pimcore.object.classes.data.da
$super();

this.specificPanel.removeAll();
this.specificPanel.add([
{

var items = [];


items.push({
xtype: "numberfield",
fieldLabel: t("width"),
name: "width",
value: this.datax.width
});

if (!this.isInCustomLayoutEditor() && !this.isInClassificationStoreEditor()) {
items.push({
xtype: "numberfield",
fieldLabel: t("width"),
name: "width",
value: this.datax.width
},
{
xtype: "textfield",
fieldLabel: t("default_value"),
name: "defaultValue",
value: this.datax.defaultValue
},
{
xtype: "textfield",
fieldLabel: t("options_provider_class"),
width: 600,
name: "optionsProviderClass",
value: this.datax.optionsProviderClass
},
{
xtype: "textfield",
fieldLabel: t("options_provider_data"),
width: 600,
value: this.datax.optionsProviderData,
name: "optionsProviderData"
},
this.valueGrid
]);
fieldLabel: t("columnlength"),
name: "columnLength",
value: this.datax.columnLength
});
}

items.push({
xtype: "textfield",
fieldLabel: t("default_value"),
name: "defaultValue",
value: this.datax.defaultValue
});

items.push({
xtype: "textfield",
fieldLabel: t("options_provider_class"),
width: 600,
name: "optionsProviderClass",
value: this.datax.optionsProviderClass
});

items.push({
xtype: "textfield",
fieldLabel: t("options_provider_data"),
width: 600,
value: this.datax.optionsProviderData,
name: "optionsProviderData"
});

items.push(this.valueGrid);

this.specificPanel.add(items);

return this.layout;
},
Expand Down