¨4.0.1¨

This commit is contained in:
¨NW¨
2023-12-03 14:07:47 +00:00
parent c08b36d1b6
commit f35052522d
1112 changed files with 43019 additions and 24987 deletions

View File

@@ -3,7 +3,7 @@ export default class {
for (let key in errors) {
let inputField = this.getInputFieldForErrorKey(key);
inputField.closest('.option').addClass('option-has-errors');
inputField.closest(".option").addClass("option-has-errors");
let parent = inputField.parent();
@@ -12,7 +12,7 @@ export default class {
}
getRowTemplate(data) {
let template = _.template($('#option-select-values-template').html());
let template = _.template($("#option-select-values-template").html());
return $(template(data));
}
@@ -20,13 +20,16 @@ export default class {
changeOptionType({ optionId, type, values = [] }) {
let optionValuesElement = this.getOptionValuesElement(optionId);
let templateType = this.getTemplateType(type, optionValuesElement);
let optionValuesData = { optionId, value: { id: '', label: '', price: '', price_type: 'fixed' } };
let optionValuesData = {
optionId,
value: { id: "", label: "", price: "", price_type: "fixed" },
};
if (this.shouldNotChangeTemplate(templateType, optionValuesElement)) {
return;
}
if (values.length !== 0 && templateType === 'text') {
if (values.length !== 0 && templateType === "text") {
optionValuesData.value = values[0];
}
@@ -34,13 +37,13 @@ export default class {
optionValuesElement.html(template(optionValuesData));
if (templateType === 'select') {
if (templateType === "select") {
this.addOptionRowEventListener(optionId);
this.addOptionRows({ optionId, values });
if (values.length === 0) {
this.getAddNewRowButton(optionId).trigger('click');
this.getAddNewRowButton(optionId).trigger("click");
}
}
}
@@ -57,41 +60,53 @@ export default class {
getTemplateType(type) {
if (this.templateTypeIsText(type)) {
return 'text';
return "text";
}
if (this.templateTypeIsSelect(type)) {
return 'select';
return "select";
}
}
templateTypeIsText(type) {
return ['field', 'textarea', 'date', 'date_time', 'time'].includes(type);
return ["field", "textarea", "date", "date_time", "time"].includes(
type
);
}
templateTypeIsSelect(type) {
return ['dropdown', 'checkbox', 'checkbox_custom', 'radio', 'radio_custom', 'multiple_select'].includes(type);
return [
"dropdown",
"checkbox",
"checkbox_custom",
"radio",
"radio_custom",
"multiple_select",
].includes(type);
}
shouldNotChangeTemplate(templateType, optionValuesElement) {
return templateType === undefined || this.alreadyHasCurrentTemplate(templateType, optionValuesElement);
return (
templateType === undefined ||
this.alreadyHasCurrentTemplate(templateType, optionValuesElement)
);
}
alreadyHasCurrentTemplate(templateType, optionValuesElement) {
if (templateType === 'text') {
return optionValuesElement.children().hasClass('option-text');
if (templateType === "text") {
return optionValuesElement.children().hasClass("option-text");
}
if (templateType === 'select') {
return optionValuesElement.children().hasClass('option-select');
if (templateType === "select") {
return optionValuesElement.children().hasClass("option-select");
}
}
initOptionRow(template, selectValues) {
if (selectValues.length !== 0 && ! selectValues.is('.sortable')) {
if (selectValues.length !== 0 && !selectValues.is(".sortable")) {
this.makeSortable(selectValues[0]);
selectValues.addClass('sortable');
selectValues.addClass("sortable");
}
this.deleteOptionRowEventListener(template);
@@ -100,14 +115,14 @@ export default class {
}
deleteOptionRowEventListener(row) {
row.find('.delete-row').on('click', (e) => {
$(e.currentTarget).closest('.option-row').remove();
row.find(".delete-row").on("click", (e) => {
$(e.currentTarget).closest(".option-row").remove();
});
}
makeSortable(el) {
Sortable.create(el, {
handle: '.drag-icon',
handle: ".drag-handle",
animation: 150,
});
}

View File

@@ -1,10 +1,5 @@
import Option from './Option';
import ProductOption from './ProductOption';
import Option from "./Option";
if ($('#option-create-form, #option-edit-form').length !== 0) {
if ($("#option-create-form, #option-edit-form").length !== 0) {
new Option();
}
if ($('#product-create-form, #product-edit-form').length !== 0) {
new ProductOption();
}

View File

@@ -1,37 +1,64 @@
.new-option {
.checkbox {
margin: 30px 0 0;
display: inline-block;
.options-group {
.option-values {
margin-top: 15px;
}
}
.delete-option {
margin-top: 25px;
padding: 10px 15px;
.new-option {
overflow: hidden;
margin-bottom: -15px;
.checkbox {
margin: 26px 0 0;
display: inline-block;
}
}
.options-group-wrapper {
.panel-title a {
.panel-title [data-toggle="collapse"] {
font-size: 14px;
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
padding: 9px 15px;
text-decoration: none;
overflow: hidden;
cursor: pointer;
> .drag-icon {
&:after {
top: 11px !important;
}
.drag-handle {
font-size: 16px;
color: #737881;
cursor: move;
vertical-align: top;
margin: 4px 10px 0 0;
margin-right: 11px;
white-space: nowrap;
display: inline-block;
i {
float: left;
cursor: move;
i {
&:nth-child(2) {
margin-left: 1px;
margin-left: -3px;
}
}
}
.delete-option {
width: 30px;
display: flex;
align-items: center;
align-self: stretch;
justify-content: center;
margin-right: 20px;
color: #4d4d4d;
transition: 150ms ease-in-out;
cursor: pointer;
&:hover {
color: #333333;
}
}
}
.form-group {
@@ -47,7 +74,7 @@
thead th {
&:first-child {
width: 40px;
width: 35px;
}
&:last-child {
@@ -76,39 +103,8 @@
}
}
.add-global-option {
.form-group {
margin-left: 0 !important;
margin-right: 10px !important;
}
> button {
margin-bottom: 15px;
}
}
@media screen and (max-width: 1199px) {
.add-global-option {
float: none !important;
clear: both;
}
.new-option {
.checkbox {
margin-top: 4px;
}
.delete-option {
margin-top: 0;
}
.p-l-0 {
padding-right: 0;
}
}
.options-group-wrapper {
.options-group {
.option-values {
.option-text,
.option-select {
@@ -120,8 +116,82 @@
@media screen and (max-width: 991px) {
.new-option {
.form-group {
label {
margin-bottom: 6px;
padding-top: 0;
}
}
.checkbox {
padding-top: 7px;
padding-top: 8px;
label {
padding-top: 0;
}
}
}
}
@media screen and (min-width: 768px) {
.new-option {
> .row {
> .col-sm-6 {
padding-right: 10px;
}
> .col-sm-3 {
padding-left: 10px;
padding-right: 10px;
}
}
}
}
@media screen and (max-width: 767px) {
.options-group {
.option-values {
margin-top: 20px;
.option-select {
.table {
> tbody {
> tr {
> td {
&:nth-child(2) {
min-width: 160px;
}
&:nth-child(3) {
min-width: 145px;
}
&:nth-child(4) {
min-width: 110px;
}
}
}
}
}
}
}
}
.new-option {
margin-bottom: -10px;
> .row {
> div {
&:nth-child(3) {
.form-group {
margin-bottom: 10px;
}
}
}
}
.checkbox {
margin-top: -3px;
}
}
}

View File

@@ -3,8 +3,7 @@
return [
'option' => 'Option',
'options' => 'Options',
'select_global_option' => 'Select Global Option',
'please_select_a_option_type' => 'Please select a option type.',
'please_select_a_option_type' => 'Please select a option type',
'table' => [
'name' => 'Name',
'type' => 'Type',
@@ -15,15 +14,9 @@ return [
],
'general' => 'General',
'values' => 'Values',
'product' => [
'options' => 'Options',
],
],
'form' => [
'this_option_is_required' => 'This option is required',
'add_new_option' => 'Add New Option',
'add_global_option' => 'Add Global Option',
'new_option' => 'New Option',
'option_types' => [
'please_select' => 'Please Select',
'text' => 'Text',
@@ -46,7 +39,7 @@ return [
'fixed' => 'Fixed',
'percent' => 'Percent',
],
'add_new_row' => 'Add New Row',
'add_row' => 'Add Row',
'delete_row' => 'Delete Row',
],
];

View File

@@ -16,3 +16,10 @@
@endsection
@include('option::admin.options.partials.scripts')
@push('globals')
@vite([
'Modules/Option/Resources/assets/admin/sass/main.scss',
'Modules/Option/Resources/assets/admin/js/main.js',
])
@endpush

View File

@@ -18,3 +18,10 @@
@endsection
@include('option::admin.options.partials.scripts')
@push('globals')
@vite([
'Modules/Option/Resources/assets/admin/sass/main.scss',
'Modules/Option/Resources/assets/admin/js/main.js',
])
@endpush

View File

@@ -24,7 +24,7 @@
@endcomponent
@push('scripts')
<script>
<script type="module">
new DataTable('#options-table .table', {
columns: [
{ data: 'checkbox', orderable: false, searchable: false, width: '3%' },

View File

@@ -1,10 +1,3 @@
@push('globals')
<script>
FleetCart.data['option.values'] = {!! old_json('values', $option->values) !!};
FleetCart.errors['option.values'] = @json($errors->get('values.*'), JSON_FORCE_OBJECT);
</script>
@endpush
@push('shortcuts')
<dl class="dl-horizontal">
<dt><code>b</code></dt>
@@ -12,8 +5,15 @@
</dl>
@endpush
@push('scripts')
@push('globals')
<script>
FleetCart.data['option.values'] = {!! old_json('values', $option->values) !!};
FleetCart.errors['option.values'] = @json($errors->get('values.*'), JSON_FORCE_OBJECT);
</script>
@endpush
@push('scripts')
<script type="module">
keypressAction([
{ key: 'b', route: "{{ route('admin.options.index') }}" },
]);

View File

@@ -33,7 +33,7 @@
id="option-<%- optionId %>-add-new-row"
<% } %>
>
{{ trans('option::options.form.add_new_row') }}
{{ trans('option::options.form.add_row') }}
</button>
</div>
</script>

View File

@@ -1,7 +1,7 @@
<script type="text/html" id="option-select-values-template">
<tr class="option-row">
<td class="text-center">
<span class="drag-icon">
<span class="drag-handle">
<i class="fa">&#xf142;</i>
<i class="fa">&#xf142;</i>
</span>