Skip to content

Commit

Permalink
Fix searchable attribute on fields not cloning, importing or exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed May 13, 2020
1 parent b43bed6 commit 51fdf5f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 27 deletions.
32 changes: 26 additions & 6 deletions config.codekit3
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"uuidString": "ECE3F09A-2816-43C6-9715-3F4A30BD28C5"
}
],
"creatorBuild": "31934",
"creatorBuild": "32137",
"files": {
"/.github/ISSUE_TEMPLATE": {
"cB": 0,
Expand Down Expand Up @@ -363,14 +363,14 @@
"aP": 1,
"bl": 0,
"dP": 10,
"dS": 0,
"ec": 1,
"ft": 4,
"ma": 0,
"oA": 0,
"oAP": "/src/resources/dist/css/field-manager.css",
"oF": 0,
"oS": 3,
"uL": 1
"sct": 1
},
"/src/services": {
"ft": 65536,
Expand Down Expand Up @@ -998,6 +998,10 @@
"active": 0,
"optionString": ""
},
"grouped-accessor-pairs": {
"active": 0,
"optionString": "'anyOrder'"
},
"guard-for-in": {
"active": 0,
"optionString": ""
Expand Down Expand Up @@ -1174,6 +1178,10 @@
"active": 1,
"optionString": "{'checkLoops': true}"
},
"no-constructor-return": {
"active": 0,
"optionString": ""
},
"no-continue": {
"active": 0,
"optionString": ""
Expand Down Expand Up @@ -1202,6 +1210,10 @@
"active": 1,
"optionString": ""
},
"no-dupe-else-if": {
"active": 1,
"optionString": ""
},
"no-dupe-keys": {
"active": 1,
"optionString": ""
Expand Down Expand Up @@ -1502,6 +1514,10 @@
"active": 0,
"optionString": ""
},
"no-setter-return": {
"active": 1,
"optionString": ""
},
"no-shadow": {
"active": 0,
"optionString": "{'builtinGlobals': false, 'hoist': 'functions', 'allow': []}"
Expand Down Expand Up @@ -1706,6 +1722,10 @@
"active": 0,
"optionString": "{'array': true, 'object': true}, {'enforceForRenamedProperties': false}"
},
"prefer-exponentiation-operator": {
"active": 0,
"optionString": ""
},
"prefer-named-capture-group": {
"active": 0,
"optionString": ""
Expand Down Expand Up @@ -2402,13 +2422,13 @@
"autoOutputPathReplace1": "sass",
"autoOutputPathReplace2": "css",
"autoOutputPathStyle": 2,
"compilerType": 1,
"createSourceMap": 0,
"debugStyle": 0,
"decimalPrecision": 10,
"emitCharset": 1,
"outputStyle": 3,
"shouldRunAutoprefixer": 1,
"shouldRunBless": 0,
"useLibsass": 1
"shouldRunBless": 0
},
"languageDefaultsSLIM": {
"autoOutputAction": 0,
Expand Down
11 changes: 7 additions & 4 deletions src/services/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function export(array $fieldIds)
'handle' => $field->handle,
'instructions' => $field->instructions,
'required' => $field->required,
'searchable' => $field->searchable,
'translationMethod' => $field->translationMethod,
'translationKeyFormat' => $field->translationKeyFormat,
'type' => \get_class($field),
Expand Down Expand Up @@ -80,8 +81,9 @@ public function processMatrix($field)
'handle' => $blockField->handle,
'required' => $blockField->required,
'instructions' => $blockField->instructions,
'translationMethod' => $field->translationMethod,
'translationKeyFormat' => $field->translationKeyFormat,
'searchable' => $blockField->searchable,
'translationMethod' => $blockField->translationMethod,
'translationKeyFormat' => $blockField->translationKeyFormat,
'type' => \get_class($blockField),
'typesettings' => $settings,
);
Expand Down Expand Up @@ -165,8 +167,9 @@ public function processSuperTable($field)
'handle' => $blockField->handle,
'required' => $blockField->required,
'instructions' => $blockField->instructions,
'translationMethod' => $field->translationMethod,
'translationKeyFormat' => $field->translationKeyFormat,
'searchable' => $blockField->searchable,
'translationMethod' => $blockField->translationMethod,
'translationKeyFormat' => $blockField->translationKeyFormat,
'type' => \get_class($blockField),
'typesettings' => $settings,
);
Expand Down
17 changes: 9 additions & 8 deletions src/services/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,16 @@ public function import(array $fields): array
}

$field = Craft::$app->fields->createField([
'groupId' => $fieldInfo['groupId'],
'name' => $fieldInfo['name'],
'handle' => $fieldInfo['handle'],
'instructions' => $fieldInfo['instructions'],
'translationMethod' => $fieldInfo['translationMethod'] ?? '',
'groupId' => $fieldInfo['groupId'],
'name' => $fieldInfo['name'],
'handle' => $fieldInfo['handle'],
'instructions' => $fieldInfo['instructions'],
'searchable' => $fieldInfo['searchable'],
'translationMethod' => $fieldInfo['translationMethod'] ?? '',
'translationKeyFormat' => $fieldInfo['translationKeyFormat'] ?? '',
'required' => $fieldInfo['required'],
'type' => $fieldInfo['type'],
'settings' => $fieldInfo['settings'],
'required' => $fieldInfo['required'],
'type' => $fieldInfo['type'],
'settings' => $fieldInfo['settings'],
]);

// Send off to Craft's native fieldSave service for heavy lifting.
Expand Down
21 changes: 12 additions & 9 deletions src/services/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ public function cloneGroup(FieldGroup $group, $prefix, FieldGroup $originGroup):

foreach (Craft::$app->fields->getFieldsByGroupId($originGroup->id) as $originField) {
$field = Craft::$app->fields->createField([
'type' => \get_class($originField),
'groupId' => $group->id,
'name' => $originField->name,
'handle' => $prefix . $originField->handle,
'instructions' => $originField->instructions,
'translationMethod' => $originField->translationMethod,
'type' => \get_class($originField),
'groupId' => $group->id,
'name' => $originField->name,
'handle' => $prefix . $originField->handle,
'instructions' => $originField->instructions,
'searchable' => $originField->searchable,
'translationMethod' => $originField->translationMethod,
'translationKeyFormat' => $originField->translationKeyFormat,
'settings' => $originField->settings,
'settings' => $originField->settings,
]);

if (get_class($field) == 'craft\fields\Matrix') {
Expand Down Expand Up @@ -128,19 +129,20 @@ public function processCloneMatrix(FieldInterface $originField)
$fields = [];

foreach ($blockType->getFields() as $j => $blockField) {
$fields['new' . $j] = [
$fields['new' . ($j + 1)] = [
'type' => get_class($blockField),
'name' => $blockField['name'],
'handle' => $blockField['handle'],
'instructions' => $blockField['instructions'],
'required' => (bool)$blockField['required'],
'searchable' => (bool)$blockField['searchable'],
'translationMethod' => $blockField['translationMethod'],
'translationKeyFormat' => $blockField['translationKeyFormat'],
'typesettings' => $blockField['settings'],
];
}

$blockTypes['new' . $i] = [
$blockTypes['new' . ($i + 1)] = [
'name' => $blockType->name,
'handle' => $blockType->handle,
'sortOrder' => $blockType->sortOrder,
Expand Down Expand Up @@ -193,6 +195,7 @@ public function processCloneSuperTable(FieldInterface $originField)
'handle' => $blockField['handle'],
'instructions' => $blockField['instructions'],
'required' => (bool)$blockField['required'],
'searchable' => (bool)$blockField['searchable'],
'translationMethod' => $blockField['translationMethod'],
'translationKeyFormat' => $blockField['translationKeyFormat'],
'typesettings' => $blockField['settings'],
Expand Down

0 comments on commit 51fdf5f

Please sign in to comment.