diff --git a/public/plugins/vue/tt-components/css/tt-position-manager.css b/public/plugins/vue/tt-components/css/tt-position-manager.css index 679e04983..d9b702ee8 100644 --- a/public/plugins/vue/tt-components/css/tt-position-manager.css +++ b/public/plugins/vue/tt-components/css/tt-position-manager.css @@ -28,8 +28,7 @@ .positions-manager .form-container [class*="tt-input"], .positions-manager .form-container [class*="tt-checkbox"] { - flex: 1 1 200px; /* Flexible width with a minimum of 200px */ - min-width: 200px; + flex: 1 1; /* Flexible width with a minimum of 200px */ } .positions-manager .form-container .btn { diff --git a/public/plugins/vue/tt-components/css/tt-table.css b/public/plugins/vue/tt-components/css/tt-table.css index 5cd8b44b9..d52c9e9a9 100644 --- a/public/plugins/vue/tt-components/css/tt-table.css +++ b/public/plugins/vue/tt-components/css/tt-table.css @@ -225,6 +225,7 @@ td { .width-80 { width: 80px; } + .width-120 { width: 120px; } @@ -254,7 +255,6 @@ td { } - /*TODO: remove this*/ /* Styles for the component */ .tt-expandable-shopping-cart { @@ -313,7 +313,7 @@ td { } .tt-expandable-shopping-cart.expanded .cart-content { - padding-top: 8px; + padding-top: 8px; } .tt-expandable-shopping-cart.expanded .cart-content h3 { @@ -359,10 +359,21 @@ td { } @keyframes spin { - to { transform: rotate(360deg); } + to { + transform: rotate(360deg); + } } .btn-loading { cursor: not-allowed; opacity: 0.7; } + +/* tt-input-article */ +.tt-input-article-wrapper .autocomplete { + display: flex; +} + +.tt-input-article-wrapper button[type=button].btn-link.position-absolute { + right: 30px !important; +} \ No newline at end of file diff --git a/public/js/pages/WarehouseArticle/WarehouseArticleModal.js b/public/plugins/vue/tt-components/tt-input-article.js similarity index 76% rename from public/js/pages/WarehouseArticle/WarehouseArticleModal.js rename to public/plugins/vue/tt-components/tt-input-article.js index 10f564f9b..4f545e439 100644 --- a/public/js/pages/WarehouseArticle/WarehouseArticleModal.js +++ b/public/plugins/vue/tt-components/tt-input-article.js @@ -252,3 +252,112 @@ Vue.component('warehouse-article-modal', { } } }) + + + +Vue.component('tt-input-article', { + template: ` +
+ + + + + + +
+ `, + props: { + value: { type: [String, Number] }, + label: { type: String, required: false }, + apiUrl: { type: String, default: '/WarehouseArticle/autoComplete' }, + placeholder: { type: String, default: '' }, + items: { type: Array, default: () => [] }, + sm: { type: Boolean, default: true }, + row: { type: Boolean, default: false }, + returnText: { type: Boolean, default: false }, + emitDisplayValue: { type: Boolean, default: true }, + caseInsensitive: { type: Boolean, default: false }, + field: { type: Object, default: () => ({}) }, + }, + data() { + return { + window, + showArticleModal: false + }; + }, + computed: { + fullApiUrl() { + // Ensure the API URL has the base path + return this.apiUrl.startsWith('/') ? + window.TT_CONFIG.BASE_PATH + this.apiUrl : + this.apiUrl; + }, + wrapperStyle() { + return this.field && this.field.style ? this.field.style : ''; + } + }, + methods: { + openArticleModal() { + this.showArticleModal = true; + }, + + handleArticleSelected(article) { + if (!article) return; + + // Update the value (article ID) + this.$emit('input', article.id); + + // Update the display text (article title) + if (this.emitDisplayValue) { + this.$emit('displayValue', article.title); + } + + // Force the autocomplete component to update + if (this.$refs.autocomplete && typeof this.$refs.autocomplete.updateDisplayValue === 'function') { + this.$refs.autocomplete.displayValue = article.title; + } + }, + + updateValue(val) { + this.$emit('input', val); + }, + + updateDisplayValue(val) { + if (this.emitDisplayValue) { + this.$emit('displayValue', val); + } + }, + + clear() { + if (this.$refs.autocomplete && typeof this.$refs.autocomplete.clear === 'function') { + this.$refs.autocomplete.clear(); + } + } + } +}); \ No newline at end of file diff --git a/public/plugins/vue/tt-components/tt-position-manager.js b/public/plugins/vue/tt-components/tt-position-manager.js index d0a99b37d..4252bde86 100644 --- a/public/plugins/vue/tt-components/tt-position-manager.js +++ b/public/plugins/vue/tt-components/tt-position-manager.js @@ -76,7 +76,19 @@ Vue.component('tt-positions-manager', :api-url="window.TT_CONFIG['BASE_PATH'] + field.apiUrl" sm /> - +