diff --git a/.gitignore b/.gitignore index a7e43607..bab26aef 100644 --- a/.gitignore +++ b/.gitignore @@ -190,3 +190,6 @@ dist .pnp.* .idea + +#history +.history diff --git a/package.json b/package.json index 08637bbf..f312f72e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@al/core", - "version": "1.0.196", + "version": "1.0.197", "description": "Node Enterprise Packages for Alert Logic (NEPAL) Core Library", "main": "./dist/index.cjs.js", "types": "./dist/index.d.ts", diff --git a/ps_spec.yml b/ps_spec.yml index 47fc2cdd..93c1e7a4 100644 --- a/ps_spec.yml +++ b/ps_spec.yml @@ -8,14 +8,13 @@ stages: - pull_request - pull_request: trigger_phrase: test it - image: node:13 + image: public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:4.0 compute_size: small commands: - npm install - - echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list - - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - - - apt-get update && apt-get -y install google-chrome-stable jq - - export CHROME_BIN='/usr/bin/google-chrome' + - curl https://intoli.com/install-google-chrome.sh | bash + - mv /usr/bin/google-chrome-stable /usr/bin/google-chrome + - google-chrome --version && which google-chrome - npm run test - npm run lint - npm run build @@ -60,13 +59,12 @@ stages: name: Master Push - Publish when: - push: ['master'] - image: node:13 + image: public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:4.0 compute_size: small commands: - - echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list - - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - - - apt-get update && apt-get -y install google-chrome-stable - - export CHROME_BIN='/usr/bin/google-chrome' + - curl https://intoli.com/install-google-chrome.sh | bash + - mv /usr/bin/google-chrome-stable /usr/bin/google-chrome + - google-chrome --version && which google-chrome - | set -ex diff --git a/src/common/cardstack/al-cardstack-view.ts b/src/common/cardstack/al-cardstack-view.ts index 0c30dd24..eba7db56 100644 --- a/src/common/cardstack/al-cardstack-view.ts +++ b/src/common/cardstack/al-cardstack-view.ts @@ -299,10 +299,10 @@ export abstract class AlCardstackView< EntityType=any, /** * Applies a filter to the current view, optionally specifying a custom filter callback. */ - public applyFilterBy( vDescriptor:AlCardstackValueDescriptor, + public applyFilterBy( vDescriptor:AlCardstackValueDescriptor, resetActiveFilters: boolean = false, callback?:{(entity:EntityType,properties:PropertyType,filter:AlCardstackActiveFilter):boolean} ) { - this.updateActiveFilters(vDescriptor, callback); + this.updateActiveFilters(vDescriptor, resetActiveFilters, callback); const pDescriptor = this.getProperty( vDescriptor.property ); if ( pDescriptor.remote ) { this.start(); // restart view @@ -315,11 +315,11 @@ export abstract class AlCardstackView< EntityType=any, /** * Applies multiple filter to the current view, optionally specifying a custom filter callback. */ - public applyMultipleFilterBy( vDescriptors:AlCardstackValueDescriptor[], + public applyMultipleFilterBy( vDescriptors:AlCardstackValueDescriptor[], resetActiveFilters: boolean = false, callback?:{(entity:EntityType,properties:PropertyType,filter:AlCardstackActiveFilter):boolean} ) { vDescriptors.forEach(vDescriptor => { - this.updateActiveFilters(vDescriptor, callback); + this.updateActiveFilters(vDescriptor, resetActiveFilters, callback); }); } @@ -708,7 +708,15 @@ export abstract class AlCardstackView< EntityType=any, return this.activeFilters.filter( filter => filter.property.remote ); } - protected updateActiveFilters(vDescriptor:AlCardstackValueDescriptor, + /** + * Updates the list of active filters based on the provided value descriptor. + * + * @param {AlCardstackValueDescriptor} vDescriptor - The value descriptor to apply as a filter. + * @param {boolean} [resetActiveFilters=false] - If true, clears all filters in the same category as the one being applied, leaving only the new filter active. + * @param {function} [callback] - An optional callback function to be called when the filter is applied. + * @returns {void} + */ + protected updateActiveFilters(vDescriptor:AlCardstackValueDescriptor, resetActiveFilters: boolean = false, callback?:{(entity:EntityType,properties:PropertyType,filter:AlCardstackActiveFilter):boolean}) { const pDescriptor = this.getProperty( vDescriptor.property ); const existing = this.activeFilters.find( filter => filter.property === pDescriptor ); @@ -716,6 +724,14 @@ export abstract class AlCardstackView< EntityType=any, if ( existing.values.includes( vDescriptor ) ) { return; // no change } + if ( resetActiveFilters ) { + existing.values = []; + pDescriptor.values.forEach(value => { + if ( vDescriptor.value !== value.value ) { + value.activeFilter = false; + } + }); + } existing.values.push( vDescriptor ); existing.rawValues = existing.values.map( vDescr => vDescr.value ); } else { diff --git a/test/common/al-cardstack.spec.ts b/test/common/al-cardstack.spec.ts index f805c51e..8ee1d67c 100644 --- a/test/common/al-cardstack.spec.ts +++ b/test/common/al-cardstack.spec.ts @@ -359,7 +359,7 @@ describe( 'AlCardstackView', () => { it( 'should show/hide items based on a custom filter', () => { let firstCard = stack.cards[0]; let color = stack.getValue( "color", firstCard.properties.color ); - stack.applyFilterBy( color, ( e, p, f ) => false ); + stack.applyFilterBy( color, false, ( e, p, f ) => false ); for ( let i = 0; i < stack.cards.length; i++ ) { let card = stack.cards[i]; expect( card.visible ).to.equal( false );