Some product rework
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
@extends('adminlte::layouts.app')
|
||||
|
||||
@section('htmlheader_title')
|
||||
{{ $o->name ?: 'New Product' }}
|
||||
@endsection
|
||||
@section('page_title')
|
||||
{{ $o->name ?: 'New Product' }}
|
||||
@endsection
|
||||
|
||||
@section('contentheader_title')
|
||||
{{ $o->name ?: 'New Product' }}
|
||||
@endsection
|
||||
@section('contentheader_description')
|
||||
@endsection
|
||||
|
||||
@section('main-content')
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('adminlte::widget.status')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark d-flex p-0">
|
||||
<ul class="nav nav-pills w-100 p-2">
|
||||
<li class="nav-item"><a class="nav-link active" href="#details" data-toggle="tab">Detail</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#services" data-toggle="tab">Services</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active show" id="details" role="tabpanel">
|
||||
@include('a.product.widgets.detail')
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="services" role="tabpanel">
|
||||
@include('a.product.widgets.services')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
@@ -1,70 +0,0 @@
|
||||
@extends('adminlte::layouts.app')
|
||||
|
||||
@section('htmlheader_title')
|
||||
Product
|
||||
@endsection
|
||||
@section('page_title')
|
||||
Product
|
||||
@endsection
|
||||
|
||||
@section('contentheader_title')
|
||||
Product
|
||||
@endsection
|
||||
@section('contentheader_description')
|
||||
@endsection
|
||||
|
||||
@section('main-content')
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header">
|
||||
<h1 class="card-title">Product Configuration</h1>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form class="g-0 needs-validation" method="POST" enctype="multipart/form-data" role="form">
|
||||
@csrf
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group has-validation">
|
||||
<label for="name">Product Name</label>
|
||||
<select class="form-control form-control-border" id="name" name="supplier_id">
|
||||
<option value=""></option>
|
||||
<option value="">Add New</option>
|
||||
@foreach(\App\Models\Product::get()->sortBy('name') as $o)
|
||||
<option value="{{ $o->id }}">{{ $o->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('name')
|
||||
{{ $message }}
|
||||
@else
|
||||
Product Name is required.
|
||||
@enderror
|
||||
</span>
|
||||
<span class="input-helper">Product Name</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('page-scripts')
|
||||
@css(select2)
|
||||
@js(select2,autofocus)
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#name').select2()
|
||||
.on('change',function(item) {
|
||||
window.location.href = '{{ url('a/product/details') }}/'+item.target.value;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
@@ -1,155 +0,0 @@
|
||||
<!-- $o = Product::class -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h3>Product Details</h3>
|
||||
<hr>
|
||||
@if(session()->has('success'))
|
||||
<span class="ml-3 pt-0 pb-0 pr-1 pl-1 btn btn-outline-success"><small>{{ session()->get('success') }}</small></span>
|
||||
@endif
|
||||
|
||||
<form class="g-0 needs-validation" method="POST" enctype="multipart/form-data" role="form">
|
||||
@csrf
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="row">
|
||||
<!-- Product Name -->
|
||||
<div class="col-9">
|
||||
<div class="form-group has-validation">
|
||||
<label for="name">Product Name</label>
|
||||
<input type="text" class="form-control form-control-border @error('description.name') is-invalid @enderror" id="name" name="description[name]" placeholder="Product Name" value="{{ old('description.name',$o->name) }}" required>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('description.name')
|
||||
{{ $message }}
|
||||
@else
|
||||
Product Name required.
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Product Active -->
|
||||
<div class="col-3">
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
|
||||
<input type="checkbox" class="custom-control-input" id="active" name="active" {{ old('active',$o->active) ? 'checked' : '' }}>
|
||||
<label class="custom-control-label" for="active">Active</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- Product Type -->
|
||||
<div class="col-4">
|
||||
<div class="form-group has-validation">
|
||||
<label for="name">Product Type</label>
|
||||
<select class="form-control form-control-border" id="model" name="model">
|
||||
<option value=""></option>
|
||||
@foreach($o->availableTypes() as $type)
|
||||
<option value="{{ $type }}" @if($o->type && ($type == get_class($o->type)))selected @endif>{{ $type }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('model')
|
||||
{{ $message }}
|
||||
@else
|
||||
Product Type required.
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- Supplied Product -->
|
||||
<div class="col-4" id="supplier_product">
|
||||
<div class="form-group has-validation">
|
||||
<label for="name">Supplied Product</label>
|
||||
<select class="form-control form-control-border" id="model_id" name="model_id">
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('model_id')
|
||||
{{ $message }}
|
||||
@else
|
||||
Supplied Product required.
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- Buttons -->
|
||||
<div class="col-12">
|
||||
<a href="{{ url('/home') }}" class="btn btn-danger">Cancel</a>
|
||||
@can('wholesaler')
|
||||
<button type="submit" name="submit" class="btn btn-success mr-0 float-right">@if ($o->exists)Save @else Add @endif</button>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('page-scripts')
|
||||
@css(select2)
|
||||
@js(select2,autofocus)
|
||||
|
||||
<script type="text/javascript">
|
||||
// Get a list of supplier items matching this type to populate model_id
|
||||
function supplier_products(type,destination,selected) {
|
||||
destination.prop('disabled',true);
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: {type: type},
|
||||
cache: false,
|
||||
url: '{{ url('api/a/supplier_products') }}',
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
// @todo add a spinner
|
||||
//spinner.toggleClass('d-none').toggleClass('fa-spin');
|
||||
alert('Failed to submit');
|
||||
},
|
||||
success: function(data) {
|
||||
destination
|
||||
.empty()
|
||||
.append($('<option>'))
|
||||
.append(data.map(function(item,key) {
|
||||
return new Option(item.name,item.id,selected && selected==item.id,selected && selected==item.id);
|
||||
}))
|
||||
.prop('disabled',false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#model').select2()
|
||||
.on('change',function(item) {
|
||||
if ($(this).val()) {
|
||||
$('#supplier_product').show();
|
||||
|
||||
|
||||
|
||||
supplier_products($(this).val(),$('#model_id'));
|
||||
|
||||
} else {
|
||||
$('#supplier_product').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#model_id').select2();
|
||||
|
||||
// After we render the page, hide the supplier_product if this product has no model.
|
||||
// We do this here, because adding d-none to the div results in the select2 input not presenting correctly
|
||||
if (! $('#model').val())
|
||||
$('#supplier_product').hide();
|
||||
else
|
||||
supplier_products($('#model').val(),$('#model_id'),{{ old('model_id',$o->model_id) }});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
Reference in New Issue
Block a user