reupload
This commit is contained in:
commit
326c677e8d
2800 files changed
+1489388
No files matched your search
@@ -0,0 +1,10 @@
|
||||
/.idea
|
||||
/vendor
|
||||
/node_modules
|
||||
package-lock.json
|
||||
composer.phar
|
||||
composer.lock
|
||||
phpunit.xml
|
||||
.phpunit.result.cache
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "nurmuhammet/inventory-history-items",
|
||||
"description": "A Laravel Nova field.",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"nova"
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^7.3|^8.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Nurmuhammet\\InventoryHistoryItems\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Nurmuhammet\\InventoryHistoryItems\\FieldServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
.grid{display:grid}.grid-col-3{grid-template-columns:1fr 1fr 1fr}.grid-col-gap-sm{grid-column-gap:6px}
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! For license information please see field.js.LICENSE.txt */
|
||||
(()=>{var t,e={4144:(t,e,r)=>{"use strict";var n={};r.r(n),r.d(n,{hasBrowserEnv:()=>ye,hasStandardBrowserEnv:()=>ve,hasStandardBrowserWebWorkerEnv:()=>ge});const o=Vue;const i={props:["index","resource","resourceName","resourceId","field"]};var a=r(6262);const s=(0,a.A)(i,[["render",function(t,e,r,n,i,a){var s=(0,o.resolveComponent)("PanelItem");return(0,o.openBlock)(),(0,o.createBlock)(s,{index:r.index,field:r.field},null,8,["index","field"])}]]);var u={key:0,class:"flex items-center"},c={class:"w-full grid grid-col-3 grid-col-gap-sm"},l=(0,o.createElementVNode)("label",{for:""},"Sany: ",-1),f=(0,o.createElementVNode)("label",{for:""},"Bahasy: ",-1),p=(0,o.createElementVNode)("label",{for:""},"Jemi: ",-1);var h=r(5379),d=r.n(h),y={nested:{type:Boolean,default:!1},preventInitialLoading:{type:Boolean,default:!1},showHelpText:{type:Boolean,default:!1},shownViaNewRelationModal:{type:Boolean,default:!1},resourceId:{type:[Number,String]},resourceName:{type:String},relatedResourceId:{type:[Number,String]},relatedResourceName:{type:String},field:{type:Object,required:!0},viaResource:{type:String,required:!1},viaResourceId:{type:[String,Number],required:!1},viaRelationship:{type:String,required:!1},relationshipType:{type:String,default:""},shouldOverrideMeta:{type:Boolean,default:!1},disablePagination:{type:Boolean,default:!1},clickAction:{type:String,default:"view",validator:function(t){return["edit","select","ignore","detail"].includes(t)}},mode:{type:String,default:"form",validator:function(t){return["form","modal","action-modal","action-fullscreen"].includes(t)}}};function v(t){return d()(y,t)}function m(){return"undefined"!=typeof navigator&&"undefined"!=typeof window?window:void 0!==r.g?r.g:{}}const g="function"==typeof Proxy,b="devtools-plugin:setup";let w,O;function E(){return void 0!==w||("undefined"!=typeof window&&window.performance?(w=!0,O=window.performance):void 0!==r.g&&(null===(t=r.g.perf_hooks)||void 0===t?void 0:t.performance)?(w=!0,O=r.g.perf_hooks.performance):w=!1),w?O.now():Date.now();var t}class S{constructor(t,e){this.target=null,this.targetQueue=[],this.onQueue=[],this.plugin=t,this.hook=e;const r={};if(t.settings)for(const e in t.settings){const n=t.settings[e];r[e]=n.defaultValue}const n=`__vue-devtools-plugin-settings__${t.id}`;let o=Object.assign({},r);try{const t=localStorage.getItem(n),e=JSON.parse(t);Object.assign(o,e)}catch(t){}this.fallbacks={getSettings:()=>o,setSettings(t){try{localStorage.setItem(n,JSON.stringify(t))}catch(t){}o=t},now:()=>E()},e&&e.on("plugin:settings:set",((t,e)=>{t===this.plugin.id&&this.fallbacks.setSettings(e)})),this.proxiedOn=new Proxy({},{get:(t,e)=>this.target?this.target.on[e]:(...t)=>{this.onQueue.push({method:e,args:t})}}),this.proxiedTarget=new Proxy({},{get:(t,e)=>this.target?this.target[e]:"on"===e?this.proxiedOn:Object.keys(this.fallbacks).includes(e)?(...t)=>(this.targetQueue.push({method:e,args:t,resolve:()=>{}}),this.fallbacks[e](...t)):(...t)=>new Promise((r=>{this.targetQueue.push({method:e,args:t,resolve:r})}))})}async setRealTarget(t){this.target=t;for(const t of this.onQueue)this.target.on[t.method](...t.args);for(const t of this.targetQueue)t.resolve(await this.target[t.method](...t.args))}}function x(t,e){const r=t,n=m(),o=m().__VUE_DEVTOOLS_GLOBAL_HOOK__,i=g&&r.enableEarlyProxy;if(!o||!n.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__&&i){const t=i?new S(r,o):null;(n.__VUE_DEVTOOLS_PLUGINS__=n.__VUE_DEVTOOLS_PLUGINS__||[]).push({pluginDescriptor:r,setupFn:e,proxy:t}),t&&e(t.proxiedTarget)}else o.emit(b,t,e)}var _="store";function A(t,e){Object.keys(t).forEach((function(r){return e(t[r],r)}))}function j(t){return null!==t&&"object"==typeof t}function P(t,e,r){return e.indexOf(t)<0&&(r&&r.prepend?e.unshift(t):e.push(t)),function(){var r=e.indexOf(t);r>-1&&e.splice(r,1)}}function R(t,e){t._actions=Object.create(null),t._mutations=Object.create(null),t._wrappedGetters=Object.create(null),t._modulesNamespaceMap=Object.create(null);var r=t.state;N(t,r,[],t._modules.root,!0),T(t,r,e)}function T(t,e,r){var n=t._state,i=t._scope;t.getters={},t._makeLocalGettersCache=Object.create(null);var a=t._wrappedGetters,s={},u={},c=(0,o.effectScope)(!0);c.run((function(){A(a,(function(e,r){s[r]=function(t,e){return function(){return t(e)}}(e,t),u[r]=(0,o.computed)((function(){return s[r]()})),Object.defineProperty(t.getters,r,{get:function(){return u[r].value},enumerable:!0})}))})),t._state=(0,o.reactive)({data:e}),t._scope=c,t.strict&&function(t){(0,o.watch)((function(){return t._state.data}),(function(){0}),{deep:!0,flush:"sync"})}(t),n&&r&&t._withCommit((function(){n.data=null})),i&&i.stop()}function N(t,e,r,n,o){var i=!r.length,a=t._modules.getNamespace(r);if(n.namespaced&&(t._modulesNamespaceMap[a],t._modulesNamespaceMap[a]=n),!i&&!o){var s=C(e,r.slice(0,-1)),u=r[r.length-1];t._withCommit((function(){s[u]=n.state}))}var c=n.context=function(t,e,r){var n=""===e,o={dispatch:n?t.dispatch:function(r,n,o){var i=k(r,n,o),a=i.payload,s=i.options,u=i.type;return s&&sLine truncated
|
||||
@@ -0,0 +1,14 @@
|
||||
/*!
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <http://feross.org>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/*!
|
||||
* vuex v4.1.0
|
||||
* (c) 2022 Evan You
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"/js/field.js": "/js/field.js",
|
||||
"/css/field.css": "/css/field.css"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
const mix = require('laravel-mix')
|
||||
const webpack = require('webpack')
|
||||
const path = require('path')
|
||||
|
||||
class NovaExtension {
|
||||
name() {
|
||||
return 'nova-extension'
|
||||
}
|
||||
|
||||
register(name) {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
webpackPlugins() {
|
||||
return new webpack.ProvidePlugin({
|
||||
_: 'lodash',
|
||||
Errors: 'form-backend-validation',
|
||||
})
|
||||
}
|
||||
|
||||
webpackConfig(webpackConfig) {
|
||||
webpackConfig.externals = {
|
||||
vue: 'Vue',
|
||||
}
|
||||
|
||||
webpackConfig.resolve.alias = {
|
||||
...(webpackConfig.resolve.alias || {}),
|
||||
'laravel-nova': path.join(
|
||||
__dirname,
|
||||
'../../vendor/laravel/nova/resources/js/mixins/packages.js'
|
||||
),
|
||||
}
|
||||
|
||||
webpackConfig.output = {
|
||||
uniqueName: this.name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mix.extend('nova', new NovaExtension())
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm run development",
|
||||
"development": "mix",
|
||||
"watch": "mix watch",
|
||||
"watch-poll": "mix watch -- --watch-options-poll=1000",
|
||||
"hot": "mix watch --hot",
|
||||
"prod": "npm run production",
|
||||
"production": "mix --production",
|
||||
"nova:install": "npm --prefix='../../vendor/laravel/nova' ci"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/compiler-sfc": "^3.2.22",
|
||||
"form-backend-validation": "^2.3.3",
|
||||
"laravel-mix": "^6.0.41",
|
||||
"lodash": "^4.17.21",
|
||||
"postcss": "^8.3.11",
|
||||
"vue-loader": "^16.8.3"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = {}
|
||||
@@ -0,0 +1,11 @@
|
||||
.grid {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.grid-col-3 {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
|
||||
.grid-col-gap-sm {
|
||||
grid-column-gap: 6px;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<PanelItem :index="index" :field="field" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: ['index', 'resource', 'resourceName', 'resourceId', 'field'],
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,231 @@
|
||||
<template>
|
||||
<DefaultField
|
||||
:field="field"
|
||||
:errors="errors"
|
||||
:show-help-text="showHelpText"
|
||||
:full-width-content="fullWidthContent"
|
||||
>
|
||||
<template #field>
|
||||
<SearchInput
|
||||
v-if="!currentlyIsReadonly"
|
||||
:data-testid="`${field.attribute}-search-input`"
|
||||
:error="hasError"
|
||||
:value="selectedOption"
|
||||
:data="options"
|
||||
@input="performSearch"
|
||||
@clear="clearSelection"
|
||||
@selected="selectOption"
|
||||
:clearable="field.nullable"
|
||||
trackBy="value"
|
||||
class="w-full"
|
||||
>
|
||||
<!-- The Selected Option Slot -->
|
||||
<div v-if="selectedOption" class="flex items-center">
|
||||
{{ selectedOption.label }}
|
||||
</div>
|
||||
|
||||
<template #option="{ selected, option }">
|
||||
<!-- Options List Slot -->
|
||||
<div
|
||||
class="flex items-center text-sm font-semibold leading-5"
|
||||
:class="{ 'text-white': selected }"
|
||||
>
|
||||
{{ option.label }}
|
||||
</div>
|
||||
</template>
|
||||
</SearchInput>
|
||||
|
||||
<div class="w-full grid grid-col-3 grid-col-gap-sm">
|
||||
<div>
|
||||
<label for="">Sany: </label>
|
||||
<input
|
||||
type="number"
|
||||
v-model="form.quantity"
|
||||
placeholder="Sany"
|
||||
class="w-full form-control form-input form-input-bordered"
|
||||
>
|
||||
</div>
|
||||
<div>
|
||||
<label for="">Bahasy: </label>
|
||||
<input
|
||||
type="text"
|
||||
v-model="form.price"
|
||||
placeholder="Bahasy"
|
||||
class="w-full form-control form-input form-input-bordered"
|
||||
disabled
|
||||
>
|
||||
</div>
|
||||
<div>
|
||||
<label for="">Jemi: </label>
|
||||
<input
|
||||
type="text"
|
||||
v-model="form.total"
|
||||
placeholder="Jemi"
|
||||
class="w-full form-control form-input form-input-bordered"
|
||||
dusk="product-item-total"
|
||||
disabled
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</DefaultField>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { DependentFormField, HandlesValidationErrors } from 'laravel-nova'
|
||||
|
||||
export default {
|
||||
mixins: [DependentFormField, HandlesValidationErrors],
|
||||
|
||||
props: ['resourceName', 'resourceId', 'field'],
|
||||
|
||||
data: () => ({
|
||||
options: [],
|
||||
search: '',
|
||||
selectedOption: null,
|
||||
form: {
|
||||
product_id: null,
|
||||
quantity: 0,
|
||||
price: 0,
|
||||
total: 0,
|
||||
}
|
||||
}),
|
||||
|
||||
mounted() {
|
||||
},
|
||||
|
||||
watch: {
|
||||
'form.quantity'() {
|
||||
this.updateProductTotal()
|
||||
},
|
||||
|
||||
selectedOption() {
|
||||
if (! this.selectedOption || ! this.selectedOption.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.form.product_id = this.selectedOption.value.id;
|
||||
this.form.price = this.selectedOption.value.cost_amount;
|
||||
|
||||
this.updateProductTotal()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
/*
|
||||
* Set the initial, internal value for the field.
|
||||
*/
|
||||
setInitialValue() {
|
||||
this.value = this.field.value || ''
|
||||
},
|
||||
|
||||
/**
|
||||
* Fill the given FormData object with the field's internal value.
|
||||
*/
|
||||
fill(formData) {
|
||||
formData.append('product_id', this.form.product_id)
|
||||
formData.append('quantity', this.form.quantity)
|
||||
formData.append('total', this.form.total)
|
||||
formData.append('cost_amount', this.form.price)
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the search string to be used to filter the select field.
|
||||
*/
|
||||
performSearch(event) {
|
||||
this.search = event
|
||||
|
||||
this.searchProducts()
|
||||
},
|
||||
|
||||
/**
|
||||
* Clear the current selection for the field.
|
||||
*/
|
||||
clearSelection() {
|
||||
this.selectedOption = null
|
||||
this.search = ''
|
||||
|
||||
this.$refs.searchable.close()
|
||||
},
|
||||
|
||||
/**
|
||||
* Select the given option.
|
||||
*/
|
||||
selectOption(option) {
|
||||
this.selectedOption = option
|
||||
this.value = option.value.id
|
||||
},
|
||||
|
||||
handleChange() {
|
||||
this.$store.commit(`${this.resourceName}/updateFilterState`, {
|
||||
filterClass: this.filterKey,
|
||||
value: this.value,
|
||||
})
|
||||
|
||||
this.$emit('change')
|
||||
},
|
||||
|
||||
serializeOptions(options) {
|
||||
return options.map(item => {
|
||||
return {
|
||||
label: item.name,
|
||||
value: item
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
updateProductTotal() {
|
||||
if (this.form.price && this.form.quantity) {
|
||||
this.form.total = this.form.price * this.form.quantity;
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.updateOveralProductTotal()
|
||||
}, 200);
|
||||
},
|
||||
|
||||
updateOveralProductTotal() {
|
||||
let totalElement = document.querySelector('[dusk="readonly_total"]');
|
||||
|
||||
if (! totalElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
let total = 0;
|
||||
document.querySelectorAll('[dusk="product-item-total"]').forEach(item => {
|
||||
total += Number(item.value)
|
||||
})
|
||||
|
||||
totalElement.value = total
|
||||
},
|
||||
|
||||
searchProducts() {
|
||||
if (! this.search && this.search.length < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Nova.$progress.start()
|
||||
|
||||
Nova.request().get(`${window.location.origin}/api/v1/search-product?internal=1&q=${encodeURIComponent(this.search)}`, {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Api-Token': 'hello-bad-mf-s',
|
||||
},
|
||||
}).then(response => {
|
||||
if (response.status !== 200) {
|
||||
this.clearSelection();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.options = this.serializeOptions(response.data.data);
|
||||
})
|
||||
|
||||
Nova.$progress.done()
|
||||
}
|
||||
},
|
||||
|
||||
computed: {},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
import DetailField from './components/DetailField'
|
||||
import FormField from './components/FormField'
|
||||
|
||||
Nova.booting((app, store) => {
|
||||
app.component('detail-inventory-history-items', DetailField)
|
||||
app.component('form-inventory-history-items', FormField)
|
||||
})
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Nurmuhammet\InventoryHistoryItems;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Nova\Events\ServingNova;
|
||||
use Laravel\Nova\Nova;
|
||||
|
||||
class FieldServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Nova::serving(function (ServingNova $event) {
|
||||
Nova::script('inventory-history-items', __DIR__.'/../dist/js/field.js');
|
||||
Nova::style('inventory-history-items', __DIR__.'/../dist/css/field.css');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Nurmuhammet\InventoryHistoryItems;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Nova\Fields\Field;
|
||||
use Laravel\Nova\Fields\SupportsDependentFields;
|
||||
|
||||
class InventoryHistoryItems extends Field
|
||||
{
|
||||
use SupportsDependentFields;
|
||||
|
||||
/**
|
||||
* The field's component.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $component = 'inventory-history-items';
|
||||
|
||||
/**
|
||||
* Set the options for the select menu.
|
||||
*
|
||||
* @param array<string|int, array<string, mixed>|string>|\Closure|callable|\Illuminate\Support\Collection $options
|
||||
*
|
||||
* @phpstan-param TOption|(callable(): (TOption))|(\Closure(): (TOption)) $options
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function options(array|Collection $options): self
|
||||
{
|
||||
return $this->withMeta([
|
||||
'options' => $this->serializeOptions($options),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize Options
|
||||
*
|
||||
* @param Collection $options
|
||||
*/
|
||||
public function serializeOptions(array|Collection $options): array|Collection
|
||||
{
|
||||
return collect($options)->map(fn ($label, $value) => ['label' => $label, 'value' => $value]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
let mix = require('laravel-mix')
|
||||
|
||||
require('./nova.mix')
|
||||
|
||||
mix
|
||||
.setPublicPath('dist')
|
||||
.js('resources/js/field.js', 'js')
|
||||
.vue({ version: 3 })
|
||||
.css('resources/css/field.css', 'css')
|
||||
.nova('nurmuhammet/inventory-history-items')
|
||||
Reference in new issue
Block a user