@@ -47,8 +47,6 @@ QCD.dashboard = (function () {
4747 registerChart ( ) ;
4848 registerButtons ( ) ;
4949 registerKanban ( ) ;
50-
51- setKanbanHeight ( ) ;
5250 }
5351
5452 function registerChart ( ) {
@@ -61,6 +59,7 @@ QCD.dashboard = (function () {
6159 let ctx = chart . chart . ctx ;
6260 let width = chart . chart . width ;
6361 let height = chart . chart . height
62+
6463 chart . clear ( ) ;
6564
6665 ctx . save ( ) ;
@@ -113,6 +112,8 @@ QCD.dashboard = (function () {
113112 }
114113 }
115114 } ) ;
115+
116+ setKanbanHeight ( ) ;
116117 }
117118 ) ;
118119 }
@@ -135,6 +136,10 @@ QCD.dashboard = (function () {
135136 }
136137
137138 function registerKanban ( ) {
139+ if ( ! $ ( "#dashboardChart" ) . length ) {
140+ setKanbanHeight ( ) ;
141+ }
142+
138143 if ( $ ( "#dashboardKanban #ordersPending" ) . length ) {
139144 $ . each ( QCD . dashboardContext . getOrdersPending ( ) , function ( index , order ) {
140145 addItem ( order ) ;
@@ -184,14 +189,20 @@ QCD.dashboard = (function () {
184189 }
185190
186191 function setKanbanHeight ( ) {
187- var containerHeight = $ ( ".container" ) . height ( ) ;
188- var dashboardButtonsHeight = $ ( "#dashboardButtons" ) . height ( ) ;
189- var dashboardChartHeight = $ ( "#dashboardChart" ) . height ( ) ;
190- var dashboardSearchHeight = $ ( "#dashboardSearch" ) . height ( ) ;
191- var dashboardPaddingHeight = 20 ;
192- var containerPaddingHeight = 20 ;
193- var cardPaddingHeight = 15 ;
194- var cardTitleHeight = $ ( ".card-title" ) . height ( ) ;
192+ let containerHeight = $ ( ".container" ) . height ( ) ;
193+ let dashboardButtonsHeight = $ ( "#dashboardButtons" ) . height ( ) ;
194+ let dashboardChartHeight = $ ( "#dashboardChart" ) . height ( ) ;
195+ let dashboardSearchHeight = $ ( "#dashboardSearch" ) . height ( ) ;
196+ let cardTitleHeight = $ ( ".card-title" ) . height ( ) ;
197+
198+ let dashboardPaddingHeight = 20 ;
199+ let cardTitlePaddingHeight = 8 ;
200+ let cardTitleMarginHeight = 12 ;
201+ let cardPaddingHeight = 16 ;
202+
203+ let headerHeight = 0 ;
204+ let height = 0 ;
205+ let marginTop = 0 ;
195206
196207 if ( dashboardButtonsHeight == undefined ) {
197208 dashboardButtonsHeight = 0 ;
@@ -201,14 +212,19 @@ QCD.dashboard = (function () {
201212 if ( dashboardChartHeight == undefined ) {
202213 dashboardChartHeight = 0 ;
203214 } else {
215+ marginTop = 40 ;
204216 dashboardChartHeight = dashboardChartHeight + dashboardPaddingHeight ;
205217 }
206218
207- var headerHeight = ( dashboardButtonsHeight > dashboardChartHeight ) ? dashboardButtonsHeight : dashboardChartHeight ;
219+ dashboardSearchHeight = dashboardSearchHeight + dashboardPaddingHeight ;
220+ cardTitleHeight = cardTitleHeight + ( cardTitlePaddingHeight * 2 ) + cardTitleMarginHeight ;
221+
222+ headerHeight = ( dashboardButtonsHeight > dashboardChartHeight ) ? dashboardButtonsHeight : dashboardChartHeight ;
208223
209- var height = containerHeight - ( containerPaddingHeight * 2 ) - headerHeight - ( cardPaddingHeight * 2 ) - dashboardSearchHeight - dashboardPaddingHeight - cardTitleHeight ;
224+ height = containerHeight - headerHeight - dashboardSearchHeight - ( cardPaddingHeight * 2 ) - cardTitleHeight + marginTop ;
210225
211- $ ( "#dashboardKanban .items" ) . css ( "height" , ( height < 300 ) ? 300 : height + "px" ) ;
226+ $ ( "#dashboardSearch" ) . css ( "margin-top" , - marginTop + "px" ) ;
227+ $ ( "#dashboardKanban .items" ) . css ( "height" , height + "px" ) ;
212228 }
213229
214230 function addItem ( item ) {
@@ -375,12 +391,19 @@ QCD.dashboard = (function () {
375391 } ) ;
376392 }
377393
394+ function filterKanbanReload ( ) {
395+ let value = $ ( "#search" ) . val ( ) ;
396+
397+ filterKanban ( value ) ;
398+ }
399+
378400 return {
379401 init : init ,
380402 initOrders : initOrders ,
381403 appendOrder : appendOrder ,
382404 prependOrder : prependOrder ,
383- prependOperationalTask : prependOperationalTask
405+ prependOperationalTask : prependOperationalTask ,
406+ filterKanbanReload : filterKanbanReload
384407 } ;
385408
386409} ) ( ) ;
@@ -467,7 +490,7 @@ const clearDrop = (event) => {
467490const updateDropzones = ( ) => {
468491 $ ( '.dropzone' ) . remove ( ) ;
469492
470- $ ( '<div class="dropzone rounded" ondrop="drop(event)" ondragover="allowDrop(event)" ondragleave="clearDrop(event)"> </div>' ) . insertAfter ( '.card.draggable' ) ;
493+ $ ( '<div class="dropzone rounded" ondrop="drop(event)" ondragover="allowDrop(event)" ondragleave="clearDrop(event)"> </div>' ) . insertAfter ( '.card .draggable' ) ;
471494
472495 $ ( ".items:not(:has(.card.draggable))" ) . append ( $ ( '<div class="dropzone rounded" ondrop="drop(event)" ondragover="allowDrop(event)" ondragleave="clearDrop(event)"> </div>' ) ) ;
473496} ;
@@ -615,27 +638,38 @@ function createOperationalTaskDiv(operationalTasksType, operationalTask) {
615638
616639 opTaskDiv = opTaskDiv + '</div>' +
617640 ( operationalTask . type == "02executionOperationInOrder" ? '<div class="card-footer">' + '<div class="progress">' + '<div class="progress-bar progress-bar-striped bg-info" role="progressbar" style="width: ' + doneInPercent + '%;" aria-valuenow="' + doneInPercent + '" aria-valuemin="0" aria-valuemax="100">' + doneInPercent + '%</div>' + '</div>' + '</div>' : '' ) +
618- '</div><div> </div>' ;
641+ '</div><div class="empty" > </div>' ;
619642
620643 return opTaskDiv ;
621644}
622645
623646function filterKanban ( value ) {
624- var results = QCD . dashboardContext . getItems ( ) . filter ( item => Object . keys ( item ) . some ( key => ( item [ key ] != null ) && item [ key ] . toString ( ) . includes ( value ) ) ) ;
647+ let keys = [ "masterOrderNumber" , "orderNumber" , "number" , "description" , "orderCategory" , "productionLineNumber" , "staffName" , "workstationNumber" , "productNumber" , "orderProductNumber" , "companyName" ] ;
648+
649+ let results = QCD . dashboardContext . getItems ( ) . filter ( item => Object . keys ( item ) . some ( key => keys . includes ( key ) && ( item [ key ] != null ) && item [ key ] . toString ( ) . includes ( value ) ) ) ;
625650
626651 if ( value == '' ) {
627652 $ ( ".items .card" ) . show ( ) ;
653+ $ ( ".items .empty" ) . show ( ) ;
654+
655+ if ( $ ( "#dashboardKanban #ordersPending" ) . length ) {
656+ updateDropzones ( ) ;
657+ }
628658 } else {
629659 $ ( ".items .card" ) . hide ( ) ;
660+ $ ( ".items .empty" ) . hide ( ) ;
661+
662+ $ ( ".dropzone" ) . remove ( ) ;
630663
631664 $ . each ( results , function ( index , item ) {
632665 $ ( "#order" + item . id ) . show ( ) ;
666+ $ ( '<div class="dropzone rounded" ondrop="drop(event)" ondragover="allowDrop(event)" ondragleave="clearDrop(event)"> </div>' ) . insertAfter ( "#order" + item . id ) ;
633667 $ ( "#operationalTask" + item . id ) . show ( ) ;
634668 } ) ;
635- }
636669
637- if ( $ ( "#dashboardKanban #ordersPending" ) . length ) {
638- updateDropzones ( ) ;
670+ if ( $ ( "#dashboardKanban #ordersPending" ) . length ) {
671+ $ ( ".items:not(:has(.card.draggable))" ) . append ( $ ( '<div class="dropzone rounded" ondrop="drop(event)" ondragover="allowDrop(event)" ondragleave="clearDrop(event)"> </div>' ) ) ;
672+ }
639673 }
640674}
641675
0 commit comments