3333 <div v-if =" mode === 'multi'" class =" form-row mt-2" >
3434 <button class =" btn btn-primary btn-sm" @click =" applyMultiSelect" >Apply Selection</button >
3535 </div >
36- <div class =" comparison-header collapsible" :class =" { expanded: comparisonEnabled }" >
37- <font-awesome-icon
38- :icon =" ['fas', 'chevron-right']"
39- fixed-width
40- class =" collapse-arrow"
41- @click =" toggleComparison"
42- />
43- <span class =" comparison-title" @click =" toggleComparison" >Comparison Files</span >
44- </div >
45- <div
46- ref =" comparisonContainer"
47- class =" comparison-content-container"
48- :style =" { 'max-height': comparisonMaxHeight }"
49- >
50- <div class =" form-row align-items-center mb-2" >
51- <FileMultiSelectDropdown
52- v-model =" comparisonFileModel"
53- :item_id =" item_id"
54- :block_id =" block_id"
55- :extensions =" blockInfo.attributes.accepted_file_extensions"
56- :update-block-on-change =" false"
57- :exclude-file-ids =" file_ids"
58- />
59- </div >
60- <div class =" form-row mt-2 mb-3" >
61- <button class =" btn btn-primary btn-sm" @click =" applyComparisonFiles" >
62- Apply Comparison Files
63- </button >
64- </div >
65- </div >
36+ <CollapsibleComparisonFileSelect
37+ v-model =" comparisonFileModel"
38+ :item_id =" item_id"
39+ :block_id =" block_id"
40+ :extensions =" blockInfo.attributes.accepted_file_extensions"
41+ :exclude-file-ids =" file_ids"
42+ :initially-expanded =" comparisonFileModel.length > 0"
43+ @apply =" applyComparisonFiles"
44+ />
6645 <div >
6746 <div class =" form-row" >
6847 <div class =" input-group form-inline" >
@@ -205,6 +184,7 @@ import DataBlockBase from "@/components/datablocks/DataBlockBase";
205184import FileSelectDropdown from " @/components/FileSelectDropdown" ;
206185import FileMultiSelectDropdown from " @/components/FileMultiSelectDropdown" ;
207186import BokehPlot from " @/components/BokehPlot" ;
187+ import CollapsibleComparisonFileSelect from " @/components/CollapsibleComparisonFileSelect" ;
208188
209189import { updateBlockFromServer } from " @/server_fetch_utils.js" ;
210190import { createComputedSetterForBlockField } from " @/field_utils.js" ;
@@ -215,6 +195,7 @@ export default {
215195 FileSelectDropdown,
216196 FileMultiSelectDropdown,
217197 BokehPlot,
198+ CollapsibleComparisonFileSelect,
218199 },
219200 props: {
220201 item_id: {
@@ -236,9 +217,6 @@ export default {
236217 isReplotButtonDisplayed: false ,
237218 pending_file_ids: [],
238219 pending_comparison_file_ids: [],
239- comparisonMaxHeight: " 0px" ,
240- padding_height: 18 ,
241- comparisonEnabled: false ,
242220 };
243221 },
244222 computed: {
@@ -313,25 +291,6 @@ export default {
313291 // Initialize pending comparison files from persisted state
314292 if (this .comparison_file_ids && Array .isArray (this .comparison_file_ids )) {
315293 this .pending_comparison_file_ids = this .comparison_file_ids .slice ();
316- // Auto-expand if there are comparison files
317- this .comparisonEnabled = this .comparison_file_ids .length > 0 ;
318- }
319-
320- // Initialize comparison section collapse state
321- var comparisonContent = this .$refs .comparisonContainer ;
322- if (comparisonContent) {
323- if (this .comparisonEnabled ) {
324- this .comparisonMaxHeight = " none" ;
325- comparisonContent .style .overflow = " visible" ;
326- } else {
327- this .comparisonMaxHeight = " 0px" ;
328- }
329-
330- comparisonContent .addEventListener (" transitionend" , () => {
331- if (this .comparisonEnabled ) {
332- this .comparisonMaxHeight = " none" ;
333- }
334- });
335294 }
336295 },
337296 methods: {
@@ -385,23 +344,6 @@ export default {
385344 this .comparison_file_ids = this .pending_comparison_file_ids .slice ();
386345 this .updateBlock ();
387346 },
388- toggleComparison () {
389- var content = this .$refs .comparisonContainer ;
390- if (! this .comparisonEnabled ) {
391- this .comparisonMaxHeight = content .scrollHeight + 2 * this .padding_height + " px" ;
392- this .comparisonEnabled = true ;
393- content .style .overflow = " visible" ;
394- } else {
395- content .style .overflow = " hidden" ;
396- requestAnimationFrame (() => {
397- this .comparisonMaxHeight = content .scrollHeight + " px" ;
398- requestAnimationFrame (() => {
399- this .comparisonMaxHeight = " 0px" ;
400- this .comparisonEnabled = false ;
401- });
402- });
403- }
404- },
405347 updateBlock () {
406348 updateBlockFromServer (
407349 this .item_id ,
@@ -445,41 +387,4 @@ export default {
445387 border-bottom : 2px dotted #0c5460 ;
446388 text-decoration : none ;
447389}
448-
449- .comparison-header {
450- display : flex ;
451- align-items : center ;
452- margin-top : 1rem ;
453- margin-bottom : 0.5rem ;
454- cursor : pointer ;
455- }
456-
457- .comparison-title {
458- margin-left : 0.5em ;
459- font-size : 1rem ;
460- font-weight : 500 ;
461- color : #004175 ;
462- }
463-
464- .collapse-arrow {
465- color : #004175 ;
466- transition : all 0.4s ;
467- cursor : pointer ;
468- }
469-
470- .collapse-arrow :hover {
471- color : #7ca7ca ;
472- }
473-
474- .expanded .collapse-arrow {
475- -webkit-transform : rotate (90deg );
476- -moz-transform : rotate (90deg );
477- transform : rotate (90deg );
478- }
479-
480- .comparison-content-container {
481- overflow : hidden ;
482- max-height : none ;
483- transition : max-height 0.4s ease-in-out ;
484- }
485390 </style >
0 commit comments