Merge pull request #1242 from openclassify/4966

#4966 Options value editing - Text input
This commit is contained in:
profstyle1 2021-12-06 13:24:45 +03:00 committed by GitHub
commit 4e8199bdd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 7 deletions

View File

@ -0,0 +1,20 @@
<?php
use Anomaly\Streams\Platform\Database\Migration\Migration;
class VisiosoftModuleAdvsAddCustomOptionValue extends Migration
{
protected $stream = [
'slug' => 'option_configuration',
];
protected $fields = [
'custom_option' => [
'type' => 'anomaly.field_type.text',
],
];
protected $assignments = [
'custom_option'
];
}

View File

@ -396,4 +396,5 @@ return [
'page' => 'Page',
'undefined_page' => 'Undefined Page',
'id' => 'ID',
'custom_field' => 'Custom Field',
];

View File

@ -11,10 +11,10 @@
</button>
</div>
<div class="modal-body">
<div class="">
<div class="flex-row">
{% set configurationForm = form('configuration_form').entry(adv.id).get() %}
{{ form_open({id: 'configurationForm',class: 'd-flex justify-content-between'})|raw }}
{{ form_open({id: 'configurationForm',class: 'd-flex justify-content-between flex-column flex-lg-row'})|raw }}
<input type="text" name="parent_adv_id" value="{{ adv.id }}" hidden>
{{ configurationForm.fields|raw }}
<button type="submit" class="btn btn-primary btn-configuration my-auto form-control w-auto">

View File

@ -25,7 +25,7 @@ class OptionConfigurationFormFields
foreach ($options as $option)
{
if($optionValue = $productoptionsValueRepository->getWithOptionsId([$option->id]))
if($productoptionsValueRepository->getWithOptionsId([$option->id]))
{
$options_fields['option-'.$option->getId()] = [
'type' => 'anomaly.field_type.select',
@ -35,14 +35,18 @@ class OptionConfigurationFormFields
'attributes' => [
'data-id' => $option->getId(),
],
'config' => [
'options' => $optionValue->pluck('title','id')->all(),
]
];
}
}
}
$options_fields['custom_option'] = [
'type' => 'anomaly.field_type.text',
'class' => 'form-control product-custom-fields',
'required' => false,
'label' => trans('visiosoft.module.advs::field.custom_field'),
];
$fields = array_merge($options_fields, ['price', 'currency', 'stock']);
$builder->setFields($fields);

View File

@ -19,7 +19,7 @@ class OptionConfigurationFormHandler
$option_json = array();
foreach ($parameters as $key => $parameter_value) {
if (substr($key, 0, 7) === "option-") {
if (strpos($key, "option-") === 0) {
$option_id = substr($key, 7);
$option_json[$option_id] = $parameter_value;
unset($parameters[$key]);

View File

@ -29,6 +29,8 @@ class OptionConfigurationModel extends AdvsOptionConfigurationEntryModel impleme
$name = trim($option_group_value, ' ');
$name .= ' ' . $this->custom_option;
return ($add_name) ? $adv->name . ' | ' . $name : $name;
}
return null;

View File

@ -62,6 +62,8 @@ class OptionConfigurationRepository extends EntryRepository implements OptionCon
$value_entry = $this->productOptionsValueRepository->find($value);
$option_group_value .= " " . $value_entry->getName();
}
$option_group_value .= " " . $product_configuration->custom_option;
$configurations[$product_configuration->getId()] = [
'name' => $option_group_value,
'price' => $product_configuration->price,