mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-06 08:52:43 +00:00
Compare commits
18 Commits
@openstapp
...
63-replace
| Author | SHA1 | Date | |
|---|---|---|---|
|
b33beeb669
|
|||
|
d2d577c012
|
|||
|
fe517fb4aa
|
|||
|
9e26fa7a1a
|
|||
|
38fb7a398d
|
|||
|
a99e08cd68
|
|||
| a5c9d22016 | |||
|
3c49c4cf6d
|
|||
|
f2c4ee308f
|
|||
| bd09b36620 | |||
|
ca146b7761
|
|||
|
|
001f978bf9 | ||
|
|
57a5b6061b | ||
|
|
4fb5941c56 | ||
|
|
314e6a6e86 | ||
|
|
e1cc33bba2 | ||
|
|
9abd397578 | ||
|
|
69fe8c6ac8 |
5
.changeset/chilly-goats-cough.md
Normal file
5
.changeset/chilly-goats-cough.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Detail views now won't load data again if it is being navigated to from a list item
|
||||||
11
.changeset/cold-squids-remain.md
Normal file
11
.changeset/cold-squids-remain.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Refactored Opening Hours
|
||||||
|
|
||||||
|
- Migrated Opening Hours to use OnPush change detection
|
||||||
|
- Fixed a bug where opening hours would not update correctly
|
||||||
|
- Lazy-load opening hours module to keep it out of the main bundle
|
||||||
|
- Added e2e tests to verify functionality
|
||||||
|
- Changed live update status to show exact minutes starting one hour before the next change
|
||||||
5
.changeset/fair-colts-explain.md
Normal file
5
.changeset/fair-colts-explain.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Use observable chains instead of change detection in the rating component
|
||||||
5
.changeset/fluffy-lamps-count.md
Normal file
5
.changeset/fluffy-lamps-count.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Added the ability to remove and add date series from their detail page
|
||||||
5
.changeset/forty-eagles-cough.md
Normal file
5
.changeset/forty-eagles-cough.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add a way to hide action chips on list items
|
||||||
5
.changeset/orange-knives-happen.md
Normal file
5
.changeset/orange-knives-happen.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add directions to inPlace and place list items
|
||||||
9
.changeset/pink-sheep-relax.md
Normal file
9
.changeset/pink-sheep-relax.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Improved calendar descriptions
|
||||||
|
|
||||||
|
- The dashboard quick link now has a more intuitive icon
|
||||||
|
- "Recurring" has been renamed to "Week Overview"
|
||||||
|
- Long words in calendar tabs will now break instead of overflowing
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
"@openstapps/minimal-deployment": "2.0.0",
|
"@openstapps/minimal-deployment": "2.0.0",
|
||||||
"@openstapps/minimal-plugin": "2.0.0",
|
"@openstapps/minimal-plugin": "2.0.0",
|
||||||
"@openstapps/app": "2.0.0",
|
"@openstapps/app": "2.0.0",
|
||||||
"@openstapps/app-release-template": "2.0.0",
|
|
||||||
"@openstapps/api": "2.0.0",
|
"@openstapps/api": "2.0.0",
|
||||||
"@openstapps/api-cli": "2.0.0",
|
"@openstapps/api-cli": "2.0.0",
|
||||||
"@openstapps/api-plugin": "2.0.0",
|
"@openstapps/api-plugin": "2.0.0",
|
||||||
@@ -24,9 +23,13 @@
|
|||||||
"@openstapps/easy-ast": "2.0.0",
|
"@openstapps/easy-ast": "2.0.0",
|
||||||
"@openstapps/es-mapping-generator": "2.0.0",
|
"@openstapps/es-mapping-generator": "2.0.0",
|
||||||
"@openstapps/gitlab-api": "2.0.0",
|
"@openstapps/gitlab-api": "2.0.0",
|
||||||
"@openstapps/logger": "2.0.0"
|
"@openstapps/logger": "2.0.0",
|
||||||
|
"@openstapps/app-builder-image": "3.0.0-next.3",
|
||||||
|
"@openstapps/node-base": "3.0.0-next.3",
|
||||||
|
"@openstapps/node-builder": "3.0.0-next.3"
|
||||||
},
|
},
|
||||||
"changesets": [
|
"changesets": [
|
||||||
|
"bright-dryers-act",
|
||||||
"cool-jars-kiss",
|
"cool-jars-kiss",
|
||||||
"cuddly-bobcats-roll",
|
"cuddly-bobcats-roll",
|
||||||
"dull-news-appear",
|
"dull-news-appear",
|
||||||
@@ -40,9 +43,14 @@
|
|||||||
"moody-parrots-develop",
|
"moody-parrots-develop",
|
||||||
"neat-hats-trade",
|
"neat-hats-trade",
|
||||||
"new-pianos-joke",
|
"new-pianos-joke",
|
||||||
|
"pretty-timers-complain",
|
||||||
"proud-wolves-end",
|
"proud-wolves-end",
|
||||||
"quick-houses-count",
|
"quick-houses-count",
|
||||||
"rare-squids-bake",
|
"rare-squids-bake",
|
||||||
|
"serious-meals-sin",
|
||||||
|
"silent-maps-float",
|
||||||
|
"silly-news-punch",
|
||||||
|
"smart-ghosts-shout",
|
||||||
"soft-donuts-fail",
|
"soft-donuts-fail",
|
||||||
"sour-coins-visit",
|
"sour-coins-visit",
|
||||||
"spicy-snails-sort",
|
"spicy-snails-sort",
|
||||||
@@ -51,6 +59,7 @@
|
|||||||
"tall-ducks-dream",
|
"tall-ducks-dream",
|
||||||
"tame-mayflies-hug",
|
"tame-mayflies-hug",
|
||||||
"tame-rings-dream",
|
"tame-rings-dream",
|
||||||
|
"tasty-islands-smell",
|
||||||
"thick-weeks-compete",
|
"thick-weeks-compete",
|
||||||
"thin-camels-give",
|
"thin-camels-give",
|
||||||
"tidy-buses-reflect",
|
"tidy-buses-reflect",
|
||||||
|
|||||||
13
.changeset/pretty-wombats-double.md
Normal file
13
.changeset/pretty-wombats-double.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Revamp "My Courses" section on profile page
|
||||||
|
|
||||||
|
The "My Courses" section on the profile page has been improved
|
||||||
|
|
||||||
|
- It will now show the upcoming courses for the next five days
|
||||||
|
- The section header is now consistent with the other sections
|
||||||
|
- The section now uses standard list items instead of the custom solution
|
||||||
|
|
||||||
|
Additionally, the profile page component has been cleaned up.
|
||||||
8
.changeset/proud-cameras-fail.md
Normal file
8
.changeset/proud-cameras-fail.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Adjust map button and item behavior on different screen sizes
|
||||||
|
|
||||||
|
- Small screens will show the item without margins below the map actions
|
||||||
|
- Large screens will show the list item on the left side
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
'@openstapps/projectmanagement': patch
|
'@openstapps/projectmanagement': patch
|
||||||
'@openstapps/prettier-config': patch
|
'@openstapps/prettier-config': patch
|
||||||
'@openstapps/app-release-template': patch
|
|
||||||
'@openstapps/es-mapping-generator': patch
|
'@openstapps/es-mapping-generator': patch
|
||||||
'@openstapps/backend-config': patch
|
'@openstapps/backend-config': patch
|
||||||
'@openstapps/eslint-config': patch
|
'@openstapps/eslint-config': patch
|
||||||
|
|||||||
5
.changeset/sour-carpets-flash.md
Normal file
5
.changeset/sour-carpets-flash.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixed an issue that caused double and triple loading of data detail items through the route stack service
|
||||||
5
.changeset/thick-mails-peel.md
Normal file
5
.changeset/thick-mails-peel.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Map items are now native list items
|
||||||
5
.changeset/tricky-garlics-hope.md
Normal file
5
.changeset/tricky-garlics-hope.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Replaced simple links with list items in date-series detail
|
||||||
5
.changeset/wet-houses-provide.md
Normal file
5
.changeset/wet-houses-provide.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Use event title for date series instead of the generic date series title
|
||||||
5
.changeset/wicked-cheetahs-prove.md
Normal file
5
.changeset/wicked-cheetahs-prove.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@openstapps/app': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Replace moment.js with date-fns
|
||||||
@@ -7,14 +7,18 @@
|
|||||||
# ```
|
# ```
|
||||||
# To your pipeline.
|
# To your pipeline.
|
||||||
# https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html#use-rules-to-add-jobs
|
# https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html#use-rules-to-add-jobs
|
||||||
|
|
||||||
|
.limit_pipelines:
|
||||||
|
rules:
|
||||||
|
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'main' || $CI_COMMIT_BRANCH == 'develop'
|
||||||
|
when: on_success
|
||||||
|
- when: never
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- local: /backend/backend/.gitlab-ci.yml
|
- local: /backend/backend/.gitlab-ci.yml
|
||||||
- local: /frontend/app/.gitlab-ci.yml
|
- local: /frontend/app/.gitlab-ci.yml
|
||||||
- local: /.gitlab/schedules.gitlab-ci.yml
|
- local: /.gitlab/schedules.gitlab-ci.yml
|
||||||
- local: /.gitlab/publishing.gitlab-ci.yml
|
- local: /.gitlab/publishing.gitlab-ci.yml
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_MESSAGE =~ /ci: publish release$/'
|
|
||||||
when: always
|
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
TURBO_CACHE_BYPASS:
|
TURBO_CACHE_BYPASS:
|
||||||
@@ -28,7 +32,7 @@ variables:
|
|||||||
default:
|
default:
|
||||||
image: registry.gitlab.com/openstapps/openstapps/node-builder
|
image: registry.gitlab.com/openstapps/openstapps/node-builder
|
||||||
tags:
|
tags:
|
||||||
- performance
|
- saas-linux-xlarge-amd64
|
||||||
interruptible: true
|
interruptible: true
|
||||||
before_script:
|
before_script:
|
||||||
- corepack enable
|
- corepack enable
|
||||||
@@ -76,13 +80,14 @@ build:
|
|||||||
rules: &deploy-rules
|
rules: &deploy-rules
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||||
variables:
|
variables:
|
||||||
DEPLOY_ID: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
|
DEPLOY_ID: $CI_MERGE_REQUEST_IID
|
||||||
- if: $CI_COMMIT_BRANCH == 'main'
|
- if: $CI_COMMIT_BRANCH == 'main'
|
||||||
variables:
|
variables:
|
||||||
DEPLOY_ID: production
|
DEPLOY_ID: production
|
||||||
- if: $CI_COMMIT_BRANCH == 'develop'
|
- if: $CI_COMMIT_BRANCH == 'develop'
|
||||||
variables:
|
variables:
|
||||||
DEPLOY_ID: staging
|
DEPLOY_ID: staging
|
||||||
|
- !reference [.limit_pipelines, rules]
|
||||||
|
|
||||||
stop review:
|
stop review:
|
||||||
stage: build
|
stage: build
|
||||||
@@ -121,15 +126,15 @@ unit:
|
|||||||
coverage_format: cobertura
|
coverage_format: cobertura
|
||||||
path: coverage.xml
|
path: coverage.xml
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'main' || $CI_COMMIT_BRANCH == 'develop'
|
- !reference [.limit_pipelines, rules]
|
||||||
|
|
||||||
audit:
|
audit:
|
||||||
stage: audit
|
stage: audit
|
||||||
|
allow_failure: true
|
||||||
needs: []
|
needs: []
|
||||||
script:
|
script:
|
||||||
- pnpm audit --prod
|
- pnpm audit --prod
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'develop'
|
|
||||||
allow_failure: true
|
|
||||||
- if: $CI_COMMIT_BRANCH == 'main'
|
- if: $CI_COMMIT_BRANCH == 'main'
|
||||||
allow_failure: false
|
allow_failure: false
|
||||||
|
- !reference [.limit_pipelines, rules]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.limit_publishing:
|
.limit_publish_pipelines:
|
||||||
- if: $CI_PIPELINE_SOURCE != "schedule"
|
rules:
|
||||||
when: on_success
|
- if: '($CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop") && $CI_COMMIT_MESSAGE =~ /ci: publish release/ && $CI_PIPELINE_SOURCE != "schedule"'
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
stage: publish
|
stage: publish
|
||||||
@@ -12,7 +12,8 @@ deploy:
|
|||||||
paths:
|
paths:
|
||||||
- ./.deploy
|
- ./.deploy
|
||||||
- ./frontend/app/www
|
- ./frontend/app/www
|
||||||
rules: !reference [.limit_publishing]
|
rules:
|
||||||
|
- !reference [.limit_publish_pipelines, rules]
|
||||||
|
|
||||||
publish image:
|
publish image:
|
||||||
stage: publish
|
stage: publish
|
||||||
@@ -23,14 +24,15 @@ publish image:
|
|||||||
image:
|
image:
|
||||||
name: gcr.io/kaniko-project/executor:v1.12.1-debug
|
name: gcr.io/kaniko-project/executor:v1.12.1-debug
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
|
variables:
|
||||||
|
PUBLISH_TAG: next
|
||||||
script:
|
script:
|
||||||
- >
|
- >
|
||||||
/kaniko/executor
|
/kaniko/executor
|
||||||
--context "${CI_PROJECT_DIR}/${DEPLOY_DIR}"
|
--context "${CI_PROJECT_DIR}/${DEPLOY_DIR}"
|
||||||
--dockerfile "${CI_PROJECT_DIR}/${DEPLOY_DIR}/Dockerfile"
|
--dockerfile "${CI_PROJECT_DIR}/${DEPLOY_DIR}/Dockerfile"
|
||||||
--destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:$(grep -o '"version": "[^"]*' "${DEPLOY_DIR}/package.json" | cut -d'"' -f4)"
|
--destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:$(grep -o '"version": "[^"]*' "${DEPLOY_DIR}/package.json" | cut -d'"' -f4)"
|
||||||
--destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:latest"
|
--destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${PUBLISH_TAG}"
|
||||||
rules: !reference [.limit_publishing]
|
|
||||||
parallel:
|
parallel:
|
||||||
matrix:
|
matrix:
|
||||||
- IMAGE_NAME: database
|
- IMAGE_NAME: database
|
||||||
@@ -47,6 +49,11 @@ publish image:
|
|||||||
DEPLOY_DIR: .deploy/minimal-plugin
|
DEPLOY_DIR: .deploy/minimal-plugin
|
||||||
- IMAGE_NAME: app
|
- IMAGE_NAME: app
|
||||||
DEPLOY_DIR: frontend/app
|
DEPLOY_DIR: frontend/app
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == 'main'
|
||||||
|
variables:
|
||||||
|
PUBLISH_TAG: latest
|
||||||
|
- !reference [.limit_publish_pipelines, rules]
|
||||||
|
|
||||||
publish packages:
|
publish packages:
|
||||||
stage: publish
|
stage: publish
|
||||||
@@ -54,18 +61,17 @@ publish packages:
|
|||||||
variables:
|
variables:
|
||||||
GIT_STRATEGY: clone
|
GIT_STRATEGY: clone
|
||||||
GIT_DEPTH: 0
|
GIT_DEPTH: 0
|
||||||
|
PUBLISH_TAG: next
|
||||||
script:
|
script:
|
||||||
- pnpm install
|
- pnpm install
|
||||||
- pnpm build
|
- pnpm build
|
||||||
- pnpm publish -r --publish-branch ${PUBLISH_BRANCH} --tag ${PUBLISH_TAG} --no-git-checks # TODO: Git checks...
|
- pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_AUTH_TOKEN}"
|
||||||
|
- pnpm publish -r --publish-branch ${CI_COMMIT_BRANCH} --tag ${PUBLISH_TAG} --no-git-checks # TODO: Git checks...
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH == 'main'
|
- if: $CI_COMMIT_BRANCH == 'main'
|
||||||
variables:
|
variables:
|
||||||
PUBLISH_BRANCH: main
|
|
||||||
PUBLISH_TAG: latest
|
PUBLISH_TAG: latest
|
||||||
- variables:
|
- !reference [.limit_publish_pipelines, rules]
|
||||||
PUBLISH_BRANCH: $CI_COMMIT_BRANCH
|
|
||||||
PUBLISH_TAG: next
|
|
||||||
|
|
||||||
publish docs:
|
publish docs:
|
||||||
stage: publish
|
stage: publish
|
||||||
@@ -77,3 +83,6 @@ publish docs:
|
|||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == 'main'
|
||||||
|
- !reference [.limit_publish_pipelines, rules]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.limit_base_image_publishing:
|
.limit_scheduled_pipelines:
|
||||||
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_BRANCH == 'main'
|
rules:
|
||||||
when: always
|
- if: $CI_COMMIT_BRANCH == 'main' && $CI_PIPELINE_SOURCE == "schedule"
|
||||||
|
|
||||||
base image:
|
base image:
|
||||||
image: docker
|
image: docker
|
||||||
@@ -18,10 +18,9 @@ base image:
|
|||||||
docker build
|
docker build
|
||||||
-t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:$(grep -o '"version": "[^"]*' "${DEPLOY_DIR}/package.json" | cut -d'"' -f4)"
|
-t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:$(grep -o '"version": "[^"]*' "${DEPLOY_DIR}/package.json" | cut -d'"' -f4)"
|
||||||
-t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:latest" "${CI_PROJECT_DIR}/${DEPLOY_DIR}" &&
|
-t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:latest" "${CI_PROJECT_DIR}/${DEPLOY_DIR}" &&
|
||||||
docker push "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}"
|
docker push "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}" --all-tags
|
||||||
cache: {} # disable irrelevant cache for this job
|
cache: {} # disable irrelevant cache for this job
|
||||||
before_script: [] # do not run irrelevant before script for this job
|
before_script: [] # do not run irrelevant before script for this job
|
||||||
rules: !reference [.limit_base_image_publishing]
|
|
||||||
parallel:
|
parallel:
|
||||||
matrix:
|
matrix:
|
||||||
- IMAGE_NAME: node-base
|
- IMAGE_NAME: node-base
|
||||||
@@ -30,4 +29,7 @@ base image:
|
|||||||
DEPLOY_DIR: images/node-builder
|
DEPLOY_DIR: images/node-builder
|
||||||
- IMAGE_NAME: app-builder
|
- IMAGE_NAME: app-builder
|
||||||
DEPLOY_DIR: images/app-builder
|
DEPLOY_DIR: images/app-builder
|
||||||
|
- IMAGE_NAME: app-cypress
|
||||||
|
DEPLOY_DIR: images/app-cypress
|
||||||
|
rules:
|
||||||
|
- !reference [.limit_scheduled_pipelines, rules]
|
||||||
@@ -19,4 +19,4 @@ integration:
|
|||||||
junit:
|
junit:
|
||||||
- backend/backend/coverage/integration-report-junit.xml
|
- backend/backend/coverage/integration-report-junit.xml
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'main' || $CI_COMMIT_BRANCH == 'develop'
|
- !reference [.limit_pipelines, rules]
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# @openstapps/backend
|
# @openstapps/backend
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
|
- Updated dependencies [23481d0d]
|
||||||
|
- @openstapps/core-tools@3.0.0-next.4
|
||||||
|
- @openstapps/logger@3.0.0-next.4
|
||||||
|
- @openstapps/core@3.0.0-next.4
|
||||||
|
|
||||||
## 3.0.0-next.0
|
## 3.0.0-next.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/backend",
|
"name": "@openstapps/backend",
|
||||||
"description": "A reference implementation for a StApps backend",
|
"description": "A reference implementation for a StApps backend",
|
||||||
"version": "3.0.0-next.0",
|
"version": "3.0.0-next.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
|
|||||||
7
backend/database/CHANGELOG.md
Normal file
7
backend/database/CHANGELOG.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# @openstapps/database
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/database",
|
"name": "@openstapps/database",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0-next.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"files": [
|
"files": [
|
||||||
"config",
|
"config",
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# @openstapps/proxy
|
# @openstapps/proxy
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
|
- Updated dependencies [23481d0d]
|
||||||
|
- @openstapps/logger@3.0.0-next.4
|
||||||
|
|
||||||
## 3.0.0-next.0
|
## 3.0.0-next.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/proxy",
|
"name": "@openstapps/proxy",
|
||||||
"description": "NGINX proxy that is dynamically configured by a Node.js script",
|
"description": "NGINX proxy that is dynamically configured by a Node.js script",
|
||||||
"version": "3.0.0-next.0",
|
"version": "3.0.0-next.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @openstapps/backend-config
|
# @openstapps/backend-config
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
|
|
||||||
## 3.0.0-next.0
|
## 3.0.0-next.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/backend-config",
|
"name": "@openstapps/backend-config",
|
||||||
"description": "Backend Configuration for OpenStApps",
|
"description": "Backend Configuration for OpenStApps",
|
||||||
"version": "3.0.0-next.0",
|
"version": "3.0.0-next.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @openstapps/eslint-config
|
# @openstapps/eslint-config
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
|
|
||||||
## 3.0.0-next.0
|
## 3.0.0-next.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/eslint-config",
|
"name": "@openstapps/eslint-config",
|
||||||
"description": "A collection of configuration base files for StApps projects. Just an (unused) experiment for now.",
|
"description": "A collection of configuration base files for StApps projects. Just an (unused) experiment for now.",
|
||||||
"version": "3.0.0-next.0",
|
"version": "3.0.0-next.4",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"repository": "git@gitlab.com:openstapps/eslint-config.git",
|
"repository": "git@gitlab.com:openstapps/eslint-config.git",
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @openstapps/prettier-config
|
# @openstapps/prettier-config
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
|
|
||||||
## 3.0.0-next.0
|
## 3.0.0-next.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/prettier-config",
|
"name": "@openstapps/prettier-config",
|
||||||
"description": "StApps Prettier Config",
|
"description": "StApps Prettier Config",
|
||||||
"version": "3.0.0-next.0",
|
"version": "3.0.0-next.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"repository": "git@gitlab.com:openstapps/prettier-config.git",
|
"repository": "git@gitlab.com:openstapps/prettier-config.git",
|
||||||
|
|||||||
@@ -1,5 +1,22 @@
|
|||||||
# @openstapps/projectmanagement
|
# @openstapps/projectmanagement
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Major Changes
|
||||||
|
|
||||||
|
- 11c9d742: Move images to separate packages
|
||||||
|
|
||||||
|
Removed builder image due to migration to Kaniko
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 4e4c7b5c: Update release configs
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
|
- Updated dependencies [23481d0d]
|
||||||
|
- @openstapps/collection-utils@3.0.0-next.4
|
||||||
|
- @openstapps/gitlab-api@3.0.0-next.4
|
||||||
|
- @openstapps/logger@3.0.0-next.4
|
||||||
|
|
||||||
## 3.0.0-next.3
|
## 3.0.0-next.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/projectmanagement",
|
"name": "@openstapps/projectmanagement",
|
||||||
"description": "Main documentation and scripts for maintenance.",
|
"description": "Main documentation and scripts for maintenance.",
|
||||||
"version": "3.0.0-next.3",
|
"version": "3.0.0-next.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @openstapps/tsconfig
|
# @openstapps/tsconfig
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
|
|
||||||
## 3.0.0-next.0
|
## 3.0.0-next.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/tsconfig",
|
"name": "@openstapps/tsconfig",
|
||||||
"description": "The tsconfig for the openstapps project",
|
"description": "The tsconfig for the openstapps project",
|
||||||
"version": "3.0.0-next.0",
|
"version": "3.0.0-next.4",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"repository": "git@gitlab.com:openstapps/eslint-config.git",
|
"repository": "git@gitlab.com:openstapps/eslint-config.git",
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# @openstapps/minimal-connector
|
# @openstapps/minimal-connector
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
|
- Updated dependencies [23481d0d]
|
||||||
|
- @openstapps/logger@3.0.0-next.4
|
||||||
|
- @openstapps/core@3.0.0-next.4
|
||||||
|
- @openstapps/api@3.0.0-next.4
|
||||||
|
|
||||||
## 3.0.0-next.0
|
## 3.0.0-next.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/minimal-connector",
|
"name": "@openstapps/minimal-connector",
|
||||||
"description": "This is a minimal connector which serves as an example",
|
"description": "This is a minimal connector which serves as an example",
|
||||||
"version": "3.0.0-next.0",
|
"version": "3.0.0-next.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
|
|||||||
7
examples/minimal-deployment/CHANGELOG.md
Normal file
7
examples/minimal-deployment/CHANGELOG.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# @openstapps/minimal-deployment
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/minimal-deployment",
|
"name": "@openstapps/minimal-deployment",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0-next.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"files": [
|
"files": [
|
||||||
"database",
|
"database",
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
# @openstapps/minimal-plugin
|
# @openstapps/minimal-plugin
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
|
- Updated dependencies [23481d0d]
|
||||||
|
- @openstapps/api-plugin@3.0.0-next.4
|
||||||
|
- @openstapps/core-tools@3.0.0-next.4
|
||||||
|
- @openstapps/logger@3.0.0-next.4
|
||||||
|
- @openstapps/core@3.0.0-next.4
|
||||||
|
- @openstapps/api@3.0.0-next.4
|
||||||
|
|
||||||
## 3.0.0-next.0
|
## 3.0.0-next.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/minimal-plugin",
|
"name": "@openstapps/minimal-plugin",
|
||||||
"description": "Minimal Plugin",
|
"description": "Minimal Plugin",
|
||||||
"version": "3.0.0-next.0",
|
"version": "3.0.0-next.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
|
|||||||
@@ -15,8 +15,12 @@
|
|||||||
buildToolsVersions = [ "${buildToolsVersion}" ];
|
buildToolsVersions = [ "${buildToolsVersion}" ];
|
||||||
platformVersions = [ "32" ];
|
platformVersions = [ "32" ];
|
||||||
};
|
};
|
||||||
cypress = prev.cypress.overrideAttrs(prev: {
|
cypress = prev.cypress.overrideAttrs(cyPrev: rec {
|
||||||
version = "12.17.1";
|
version = "13.2.0";
|
||||||
|
src = prev.fetchzip {
|
||||||
|
url = "https://cdn.cypress.io/desktop/${version}/linux-x64/cypress.zip";
|
||||||
|
hash = "sha256-9o0nprGcJhudS1LNm+T7Vf0Dwd1RBauYKI+w1FBQ3ZM=";
|
||||||
|
};
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2020,
|
"ecmaVersion": 2020,
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"project": ["tsconfig.json", "tsconfig.spec.json", "e2e/tsconfig.e2e.json"],
|
"project": ["tsconfig.json", "tsconfig.spec.json", "cypress/tsconfig.json"],
|
||||||
"createDefaultProgram": true
|
"createDefaultProgram": true
|
||||||
},
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
e2e:
|
e2e:
|
||||||
image: cypress/browsers:latest # https://hub.docker.com/r/cypress/browsers/tags/
|
image: registry.gitlab.com/openstapps/openstapps/app-cypress:node-18
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- pnpm --filter=@openstapps/app install
|
- pnpm --filter=@openstapps/app install
|
||||||
- pnpm --filter=@openstapps/app exec cypress install
|
- pnpm --filter=@openstapps/app exec cypress install
|
||||||
|
- cd node_modules/.pnpm/re2*/node_modules/re2
|
||||||
|
- npm run install
|
||||||
|
- cd $CI_PROJECT_DIR
|
||||||
- pnpm test:integration:app
|
- pnpm test:integration:app
|
||||||
artifacts:
|
artifacts:
|
||||||
when: on_failure
|
when: on_failure
|
||||||
@@ -19,4 +22,4 @@ e2e:
|
|||||||
- BROWSER: chrome
|
- BROWSER: chrome
|
||||||
- BROWSER: firefox
|
- BROWSER: firefox
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'main' || $CI_COMMIT_BRANCH == 'develop'
|
- !reference [.limit_pipelines, rules]
|
||||||
|
|||||||
@@ -1,5 +1,29 @@
|
|||||||
# @openstapps/app
|
# @openstapps/app
|
||||||
|
|
||||||
|
## 3.0.0-next.4
|
||||||
|
|
||||||
|
### Major Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to Angular 16.1
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 23481d0d: Migrate to Ionic 7
|
||||||
|
|
||||||
|
- Migrate uses of `<ion-label>` with inputs to new syntax
|
||||||
|
- Fix infinite loop in schedule date picker (`datetime.confirm()` to `datetime.cancel()`)
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 23481d0d: Update to TypeScript 5.1.6
|
||||||
|
- bebee6b4: Migrate collection helpers to use @openstapps/collection-utils
|
||||||
|
- 107a7c5e: Migrate unit tests to karma-coverage and junit reports.
|
||||||
|
Fixes an issue where coverage reports would not be generated.
|
||||||
|
- Updated dependencies [23481d0d]
|
||||||
|
- @openstapps/collection-utils@3.0.0-next.4
|
||||||
|
- @openstapps/core@3.0.0-next.4
|
||||||
|
- @openstapps/api@3.0.0-next.4
|
||||||
|
|
||||||
## 3.0.0-next.0
|
## 3.0.0-next.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -42,3 +42,23 @@ The command `ionic cordova run ios` runs into the error `/platforms/ios/build/em
|
|||||||
|
|
||||||
- Either use the command: `ionic cordova emulate ios -- --buildFlag="-UseModernBuildSystem=0"`
|
- Either use the command: `ionic cordova emulate ios -- --buildFlag="-UseModernBuildSystem=0"`
|
||||||
- Or open the iOS project in Xcode and change build system in workspace settings to `Lagacy Build System`. Then the normal run command works also.
|
- Or open the iOS project in Xcode and change build system in workspace settings to `Lagacy Build System`. Then the normal run command works also.
|
||||||
|
|
||||||
|
## Cypress
|
||||||
|
|
||||||
|
#### Problem
|
||||||
|
|
||||||
|
The browser doesn't open or the tests don't connect to a browser
|
||||||
|
|
||||||
|
#### Cause
|
||||||
|
|
||||||
|
Cypress was installed to a read-only location, see
|
||||||
|
[this issue](https://github.com/cypress-io/cypress/issues/18893).
|
||||||
|
This can be the case if you use NixOS.
|
||||||
|
|
||||||
|
#### Solution
|
||||||
|
|
||||||
|
Make sure the cypress folder is writable before each launch
|
||||||
|
|
||||||
|
```shell
|
||||||
|
chmod -R +rw ~/.config/Cypress
|
||||||
|
```
|
||||||
|
|||||||
@@ -182,6 +182,7 @@
|
|||||||
"builder": "@cypress/schematic:cypress",
|
"builder": "@cypress/schematic:cypress",
|
||||||
"options": {
|
"options": {
|
||||||
"devServerTarget": "app:serve",
|
"devServerTarget": "app:serve",
|
||||||
|
"liveReload": false,
|
||||||
"watch": true,
|
"watch": true,
|
||||||
"headless": false
|
"headless": false
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,14 +18,18 @@
|
|||||||
|
|
||||||
describe('dashboard', async function () {
|
describe('dashboard', async function () {
|
||||||
describe('schedule section', function () {
|
describe('schedule section', function () {
|
||||||
it('should lead to the schedule', function () {
|
it('should lead to the week overview', function () {
|
||||||
cy.visit('/overview');
|
cy.visit('/overview');
|
||||||
cy.get('.schedule').contains('a', 'Stundenplan').click();
|
cy.get('.schedule')
|
||||||
cy.url().should('include', '/schedule/recurring');
|
.contains('a', /Wochen.*übersicht/)
|
||||||
|
.click();
|
||||||
|
cy.url().should('include', '/schedule/week-overview');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should lead to the calendar', function () {
|
||||||
cy.visit('/overview');
|
cy.visit('/overview');
|
||||||
cy.get('.schedule').contains('a', 'Kein Eintrag gefunden').click();
|
cy.get('.schedule').contains('a', 'Kein Eintrag gefunden').click();
|
||||||
cy.url().should('include', '/schedule/recurring');
|
cy.url().should('include', '/schedule/calendar');
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Reenable and stabilize tests
|
// TODO: Reenable and stabilize tests
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ describe('ical', function () {
|
|||||||
|
|
||||||
cy.get('ion-app > ion-modal').within(() => {
|
cy.get('ion-app > ion-modal').within(() => {
|
||||||
cy.get('ion-footer > ion-toolbar > ion-button').should('have.attr', 'disabled');
|
cy.get('ion-footer > ion-toolbar > ion-button').should('have.attr', 'disabled');
|
||||||
cy.contains('ion-item', /19\.\s+Januar\s+2059,\s+\d{2}:00\s+-\s+\d{2}:00/).click();
|
cy.contains('ion-item', /1\s+Stunde\s+Sonntag,\s+19\.\s+Januar\s+2059\s+um\s+\d{2}:00/).click();
|
||||||
cy.get('ion-footer > ion-toolbar > ion-button').should('not.have.attr', 'disabled');
|
cy.get('ion-footer > ion-toolbar > ion-button').should('not.have.attr', 'disabled');
|
||||||
cy.get('ion-footer > ion-toolbar > ion-button').click();
|
cy.get('ion-footer > ion-toolbar > ion-button').click();
|
||||||
});
|
});
|
||||||
|
|
||||||
cy.get('add-event-review-modal').within(() => {
|
cy.get('add-event-review-modal').within(() => {
|
||||||
cy.get('ion-item-group').should('contain', 'UNIcert (Test)');
|
cy.get('ion-item-group').should('contain', 'UNIcert (Test)');
|
||||||
cy.contains('ion-item-group', /19\.\s+Jan\.\s+2059,\s+\d{2}:00/);
|
cy.contains('ion-item-group', /19\.\s+Januar\s+2059\s+um\s+\d{2}:00/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
141
frontend/app/cypress/integration/opening-hours.spec.ts
Normal file
141
frontend/app/cypress/integration/opening-hours.spec.ts
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
describe('opening hours', () => {
|
||||||
|
beforeEach(function () {
|
||||||
|
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
|
||||||
|
fixture: 'search/types/canteen/canteen-search-result.json',
|
||||||
|
}).as('search');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should specify relative closing time', () => {
|
||||||
|
cy.clock(new Date(2023, 9, 16, 15, 29), ['Date']);
|
||||||
|
cy.visit('/canteen');
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geöffnet')
|
||||||
|
.should('contain', 'Schließt heute um 22:00');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should specify relative opening time', () => {
|
||||||
|
cy.clock(new Date(2023, 9, 16, 6, 29), ['Date']);
|
||||||
|
cy.visit('/canteen');
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geschlossen')
|
||||||
|
.should('contain', 'Öffnet heute um 08:30');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should specify soon opening time', () => {
|
||||||
|
cy.clock(new Date(2023, 9, 16, 8, 0), ['Date']);
|
||||||
|
cy.visit('/canteen');
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geschlossen')
|
||||||
|
.should('contain', 'Öffnet in 30 Minuten');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should specify soon closing time', () => {
|
||||||
|
cy.clock(new Date(2023, 9, 16, 21, 30), ['Date']);
|
||||||
|
cy.visit('/canteen');
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geöffnet')
|
||||||
|
.should('contain', 'Schließt in 30 Minuten');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update the soon closing time every minute', () => {
|
||||||
|
cy.clock(new Date(2023, 9, 16, 21, 30));
|
||||||
|
cy.visit('/canteen');
|
||||||
|
cy.tick(500);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geöffnet')
|
||||||
|
.should('contain', 'Schließt in 30 Minuten');
|
||||||
|
|
||||||
|
cy.tick(60_000);
|
||||||
|
cy.tick(50);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geöffnet')
|
||||||
|
.should('contain', 'Schließt in 29 Minuten');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update the status when it changes', () => {
|
||||||
|
cy.clock(new Date(2023, 9, 16, 21, 59));
|
||||||
|
cy.visit('/canteen');
|
||||||
|
cy.tick(500);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geöffnet')
|
||||||
|
.should('contain', 'Schließt in 1 Minute');
|
||||||
|
|
||||||
|
cy.tick(60_000);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geschlossen')
|
||||||
|
.should('contain', 'Öffnet morgen um 08:30');
|
||||||
|
});
|
||||||
|
|
||||||
|
// This one takes long to execute!
|
||||||
|
it('should update as expected', () => {
|
||||||
|
cy.clock(new Date(2023, 9, 16, 20, 59));
|
||||||
|
cy.visit('/canteen');
|
||||||
|
cy.tick(500);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geöffnet')
|
||||||
|
.should('contain', 'Schließt heute um 22:00');
|
||||||
|
|
||||||
|
cy.tick(60_000);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geöffnet')
|
||||||
|
.should('contain', 'Schließt in 60 Minuten');
|
||||||
|
|
||||||
|
cy.tick(30 * 60_000);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geöffnet')
|
||||||
|
.should('contain', 'Schließt in 30 Minuten');
|
||||||
|
|
||||||
|
cy.tick(30 * 60_000);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geschlossen')
|
||||||
|
.should('contain', 'Öffnet morgen um 08:30');
|
||||||
|
|
||||||
|
cy.tick(9.5 * 60 * 60_000);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geschlossen')
|
||||||
|
.should('contain', 'Öffnet in 60 Minuten');
|
||||||
|
|
||||||
|
cy.tick(30 * 60_000);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geschlossen')
|
||||||
|
.should('contain', 'Öffnet in 30 Minuten');
|
||||||
|
|
||||||
|
cy.tick(30 * 60_000);
|
||||||
|
|
||||||
|
cy.get('stapps-opening-hours')
|
||||||
|
.first()
|
||||||
|
.should('contain', 'Geöffnet')
|
||||||
|
.should('contain', 'Schließt heute um 22:00');
|
||||||
|
|
||||||
|
// Long tick warps will cause network requests to time out
|
||||||
|
cy.get('@consoleError').invoke('resetHistory');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -25,7 +25,7 @@ describe('schedule', function () {
|
|||||||
|
|
||||||
it('should respect the url', function () {
|
it('should respect the url', function () {
|
||||||
cy.visit('/schedule/calendar/2022-01-19');
|
cy.visit('/schedule/calendar/2022-01-19');
|
||||||
cy.get('#date-select-button0').should('contain', '19.01.22');
|
cy.get('#date-select-button0').should('contain', '19.01.2022');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate a full page', function () {
|
it('should navigate a full page', function () {
|
||||||
@@ -66,13 +66,13 @@ describe('schedule', function () {
|
|||||||
|
|
||||||
it('should navigate to a specific date', function () {
|
it('should navigate to a specific date', function () {
|
||||||
cy.visit('/schedule/calendar/2059-01-19');
|
cy.visit('/schedule/calendar/2059-01-19');
|
||||||
cy.contains('#date-select-button0', '19.01.59').click();
|
cy.contains('#date-select-button0', '19.01.2059').click();
|
||||||
cy.wait(2000);
|
cy.wait(2000);
|
||||||
cy.get('button[data-day=1][data-month=1][data-year=2059]', {
|
cy.get('button[data-day=1][data-month=1][data-year=2059]', {
|
||||||
includeShadowDom: true,
|
includeShadowDom: true,
|
||||||
}).click();
|
}).click();
|
||||||
cy.wait(2000);
|
cy.wait(2000);
|
||||||
cy.contains('#date-select-button0', '01.01.59').click();
|
cy.contains('#date-select-button0', '01.01.2059').click();
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Reenable and stabilize tests
|
// TODO: Reenable and stabilize tests
|
||||||
|
|||||||
@@ -31,36 +31,24 @@
|
|||||||
// When a command from ./commands is ready to use, import with `import './commands'` syntax
|
// When a command from ./commands is ready to use, import with `import './commands'` syntax
|
||||||
// import './commands';
|
// import './commands';
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(function () {
|
||||||
let databases: string[];
|
cy.wrap(
|
||||||
if (window.indexedDB.databases) {
|
new Promise(resolve => {
|
||||||
databases = (await window.indexedDB.databases()).map(it => it.name);
|
window.indexedDB.deleteDatabase('_ionicstorage').onsuccess = resolve;
|
||||||
console.log('Trying to clear all databases');
|
}),
|
||||||
} else {
|
);
|
||||||
console.log("Browser doesn't support database enumeration, deleting just ionic storage");
|
|
||||||
databases = ['_ionicstorage'];
|
|
||||||
}
|
|
||||||
for (const database of databases) {
|
|
||||||
if (database) {
|
|
||||||
console.log(`Deleting database ${database}`);
|
|
||||||
await new Promise(resolve => (window.indexedDB.deleteDatabase(database).onsuccess = resolve));
|
|
||||||
console.log(`Deleted database ${database}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.on('window:before:load', window => {
|
Cypress.on('window:before:load', window => {
|
||||||
// Fake that user is using its browser in german language
|
// Fake that user is using its browser in German
|
||||||
Object.defineProperty(window.navigator, 'language', {value: 'de-DE'});
|
Object.defineProperty(window.navigator, 'language', {value: 'de-DE'});
|
||||||
Object.defineProperty(window.navigator, 'languages', [{value: 'de-DE'}]);
|
Object.defineProperty(window.navigator, 'languages', [{value: 'de-DE'}]);
|
||||||
|
|
||||||
// Fail tests on console error
|
cy.spy(window.console, 'error').as('consoleError');
|
||||||
cy.stub(window.console, 'error').callsFake(message => {
|
});
|
||||||
// log out to the terminal
|
|
||||||
cy.now('task', 'error', message);
|
afterEach(function () {
|
||||||
// log to Command Log and fail the test
|
cy.get('@consoleError').should('not.have.been.called');
|
||||||
throw new Error(message);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.on('uncaught:exception', error => {
|
Cypress.on('uncaught:exception', error => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/app",
|
"name": "@openstapps/app",
|
||||||
"description": "The generic app tailored to fulfill needs of German universities, written using Ionic Framework.",
|
"description": "The generic app tailored to fulfill needs of German universities, written using Ionic Framework.",
|
||||||
"version": "3.0.0-next.0",
|
"version": "3.0.0-next.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
|
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"analyze": "webpack-bundle-analyzer www/stats.json",
|
"analyze": "webpack-bundle-analyzer www/stats.json",
|
||||||
"build": "pnpm check-icons && ng build --configuration=production --stats-json && webpack-bundle-analyzer www/stats.json --mode static --report www/bundle-info.html",
|
"build": "pnpm check-icons && ng build --configuration=production --stats-json && webpack-bundle-analyzer --no-open www/stats.json --mode static --report www/bundle-info.html",
|
||||||
"build:analyze": "npm run build:stats && npm run analyze",
|
"build:analyze": "npm run build:stats && npm run analyze",
|
||||||
"build:android": "ionic capacitor build android --no-open && cd android && ./gradlew clean assembleDebug && cd ..",
|
"build:android": "ionic capacitor build android --no-open && cd android && ./gradlew clean assembleDebug && cd ..",
|
||||||
"build:prod": "ng build --configuration=production",
|
"build:prod": "ng build --configuration=production",
|
||||||
@@ -63,6 +63,7 @@
|
|||||||
"@awesome-cordova-plugins/core": "5.45.0",
|
"@awesome-cordova-plugins/core": "5.45.0",
|
||||||
"@capacitor/app": "4.1.1",
|
"@capacitor/app": "4.1.1",
|
||||||
"@capacitor/browser": "4.1.0",
|
"@capacitor/browser": "4.1.0",
|
||||||
|
"@capacitor/clipboard": "4.1.0",
|
||||||
"@capacitor/core": "4.6.1",
|
"@capacitor/core": "4.6.1",
|
||||||
"@capacitor/device": "4.1.0",
|
"@capacitor/device": "4.1.0",
|
||||||
"@capacitor/dialog": "4.1.0",
|
"@capacitor/dialog": "4.1.0",
|
||||||
@@ -84,11 +85,14 @@
|
|||||||
"@ngx-translate/http-loader": "8.0.0",
|
"@ngx-translate/http-loader": "8.0.0",
|
||||||
"@openid/appauth": "1.3.1",
|
"@openid/appauth": "1.3.1",
|
||||||
"@openstapps/api": "workspace:*",
|
"@openstapps/api": "workspace:*",
|
||||||
"@openstapps/core": "workspace:*",
|
|
||||||
"@openstapps/collection-utils": "workspace:*",
|
"@openstapps/collection-utils": "workspace:*",
|
||||||
|
"@openstapps/core": "workspace:*",
|
||||||
"@transistorsoft/capacitor-background-fetch": "1.0.2",
|
"@transistorsoft/capacitor-background-fetch": "1.0.2",
|
||||||
|
"@types/dom-view-transitions": "1.0.1",
|
||||||
"capacitor-secure-storage-plugin": "0.8.1",
|
"capacitor-secure-storage-plugin": "0.8.1",
|
||||||
"cordova-plugin-calendar": "5.1.6",
|
"cordova-plugin-calendar": "5.1.6",
|
||||||
|
"date-fns": "2.30.0",
|
||||||
|
"duration-fns": "3.0.2",
|
||||||
"deepmerge": "4.3.1",
|
"deepmerge": "4.3.1",
|
||||||
"form-data": "4.0.0",
|
"form-data": "4.0.0",
|
||||||
"geojson": "0.5.0",
|
"geojson": "0.5.0",
|
||||||
@@ -97,10 +101,9 @@
|
|||||||
"leaflet": "1.9.3",
|
"leaflet": "1.9.3",
|
||||||
"leaflet.markercluster": "1.5.3",
|
"leaflet.markercluster": "1.5.3",
|
||||||
"material-symbols": "0.10.0",
|
"material-symbols": "0.10.0",
|
||||||
"moment": "2.29.4",
|
"ngx-date-fns": "10.0.1",
|
||||||
"ngx-logger": "5.0.12",
|
"ngx-logger": "5.0.12",
|
||||||
"ngx-markdown": "16.0.0",
|
"ngx-markdown": "16.0.0",
|
||||||
"ngx-moment": "6.0.2",
|
|
||||||
"opening_hours": "3.8.0",
|
"opening_hours": "3.8.0",
|
||||||
"rxjs": "7.8.1",
|
"rxjs": "7.8.1",
|
||||||
"swiper": "8.4.5",
|
"swiper": "8.4.5",
|
||||||
@@ -146,7 +149,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "5.60.1",
|
"@typescript-eslint/eslint-plugin": "5.60.1",
|
||||||
"@typescript-eslint/parser": "5.60.1",
|
"@typescript-eslint/parser": "5.60.1",
|
||||||
"cordova-res": "0.15.4",
|
"cordova-res": "0.15.4",
|
||||||
"cypress": "12.17.1",
|
"cypress": "13.2.0",
|
||||||
"eslint": "8.43.0",
|
"eslint": "8.43.0",
|
||||||
"eslint-plugin-jsdoc": "46.4.2",
|
"eslint-plugin-jsdoc": "46.4.2",
|
||||||
"eslint-plugin-prettier": "4.2.1",
|
"eslint-plugin-prettier": "4.2.1",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
import moment from 'moment';
|
import {addDays, endOfToday, formatISO, startOfToday} from 'date-fns';
|
||||||
|
|
||||||
export const sampleResources = [
|
export const sampleResources = [
|
||||||
{
|
{
|
||||||
@@ -793,8 +793,8 @@ export const sampleResources = [
|
|||||||
offers: [
|
offers: [
|
||||||
{
|
{
|
||||||
availability: 'in stock',
|
availability: 'in stock',
|
||||||
availabilityStarts: moment().startOf('day').add(2, 'days').toISOString(),
|
availabilityStarts: formatISO(addDays(startOfToday(), 2)),
|
||||||
availabilityEnds: moment().endOf('day').add(2, 'days').toISOString(),
|
availabilityEnds: formatISO(addDays(endOfToday(), 2)),
|
||||||
prices: {
|
prices: {
|
||||||
default: 6.5,
|
default: 6.5,
|
||||||
student: 5,
|
student: 5,
|
||||||
@@ -904,8 +904,8 @@ export const sampleResources = [
|
|||||||
offers: [
|
offers: [
|
||||||
{
|
{
|
||||||
availability: 'in stock',
|
availability: 'in stock',
|
||||||
availabilityStarts: moment().startOf('day').toISOString(),
|
availabilityStarts: formatISO(startOfToday()),
|
||||||
availabilityEnds: moment().endOf('day').add(2, 'days').toISOString(),
|
availabilityEnds: formatISO(addDays(endOfToday(), 2)),
|
||||||
prices: {
|
prices: {
|
||||||
default: 4.85,
|
default: 4.85,
|
||||||
student: 2.85,
|
student: 2.85,
|
||||||
@@ -984,8 +984,8 @@ export const sampleResources = [
|
|||||||
uid: '3b9b3df6-3a7a-58cc-922f-c7335c002634',
|
uid: '3b9b3df6-3a7a-58cc-922f-c7335c002634',
|
||||||
},
|
},
|
||||||
availability: 'in stock',
|
availability: 'in stock',
|
||||||
availabilityStarts: moment().startOf('day').add(2, 'days').toISOString(),
|
availabilityStarts: formatISO(addDays(startOfToday(), 2)),
|
||||||
availabilityEnds: moment().endOf('day').add(2, 'days').toISOString(),
|
availabilityEnds: formatISO(addDays(endOfToday(), 2)),
|
||||||
inPlace: {
|
inPlace: {
|
||||||
geo: {
|
geo: {
|
||||||
point: {
|
point: {
|
||||||
@@ -1046,8 +1046,8 @@ export const sampleResources = [
|
|||||||
],
|
],
|
||||||
offers: [
|
offers: [
|
||||||
{
|
{
|
||||||
availabilityEnds: moment().endOf('day').toISOString(),
|
availabilityEnds: formatISO(endOfToday()),
|
||||||
availabilityStarts: moment().startOf('day').toISOString(),
|
availabilityStarts: formatISO(startOfToday()),
|
||||||
availability: 'in stock',
|
availability: 'in stock',
|
||||||
inPlace: {
|
inPlace: {
|
||||||
type: 'room',
|
type: 'room',
|
||||||
|
|||||||
@@ -21,11 +21,8 @@ import {RouteReuseStrategy} from '@angular/router';
|
|||||||
import {IonicModule, IonicRouteStrategy, Platform} from '@ionic/angular';
|
import {IonicModule, IonicRouteStrategy, Platform} from '@ionic/angular';
|
||||||
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
|
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
|
||||||
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
|
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
|
||||||
import moment from 'moment';
|
|
||||||
import 'moment/min/locales';
|
|
||||||
import {LoggerModule, NGXLogger, NgxLoggerLevel} from 'ngx-logger';
|
import {LoggerModule, NGXLogger, NgxLoggerLevel} from 'ngx-logger';
|
||||||
import SwiperCore, {FreeMode, Navigation} from 'swiper';
|
import SwiperCore, {FreeMode, Navigation} from 'swiper';
|
||||||
|
|
||||||
import {environment} from '../environments/environment';
|
import {environment} from '../environments/environment';
|
||||||
import {AppRoutingModule} from './app-routing.module';
|
import {AppRoutingModule} from './app-routing.module';
|
||||||
import {AppComponent} from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
@@ -58,12 +55,15 @@ import {StorageProvider} from './modules/storage/storage.provider';
|
|||||||
import {AssessmentsModule} from './modules/assessments/assessments.module';
|
import {AssessmentsModule} from './modules/assessments/assessments.module';
|
||||||
import {ServiceHandlerInterceptor} from './_helpers/service-handler.interceptor';
|
import {ServiceHandlerInterceptor} from './_helpers/service-handler.interceptor';
|
||||||
import {RoutingStackService} from './util/routing-stack.service';
|
import {RoutingStackService} from './util/routing-stack.service';
|
||||||
import {SCSettingValue} from '@openstapps/core';
|
import {SCLanguageCode, SCSettingValue} from '@openstapps/core';
|
||||||
import {DefaultAuthService} from './modules/auth/default-auth.service';
|
import {DefaultAuthService} from './modules/auth/default-auth.service';
|
||||||
import {PAIAAuthService} from './modules/auth/paia/paia-auth.service';
|
import {PAIAAuthService} from './modules/auth/paia/paia-auth.service';
|
||||||
import {IonIconModule} from './util/ion-icon/ion-icon.module';
|
import {IonIconModule} from './util/ion-icon/ion-icon.module';
|
||||||
import {NavigationModule} from './modules/menu/navigation/navigation.module';
|
import {NavigationModule} from './modules/menu/navigation/navigation.module';
|
||||||
import {browserFactory, SimpleBrowser} from './util/browser.factory';
|
import {browserFactory, SimpleBrowser} from './util/browser.factory';
|
||||||
|
import {getDateFnsLocale} from './translation/dfns-locale';
|
||||||
|
import {setDefaultOptions} from 'date-fns';
|
||||||
|
import {DateFnsConfigurationService, DateFnsModule} from 'ngx-date-fns';
|
||||||
|
|
||||||
registerLocaleData(localeDe);
|
registerLocaleData(localeDe);
|
||||||
|
|
||||||
@@ -71,12 +71,6 @@ SwiperCore.use([FreeMode, Navigation]);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes data needed on startup
|
* Initializes data needed on startup
|
||||||
* @param storageProvider provider of the saved data (using framework's storage)
|
|
||||||
* @param logger TODO
|
|
||||||
* @param settingsProvider provider of settings (e.g. language that has been set)
|
|
||||||
* @param configProvider TODO
|
|
||||||
* @param translateService TODO
|
|
||||||
* @param _routingStackService Just for init and to track the stack from the get go
|
|
||||||
*/
|
*/
|
||||||
export function initializerFactory(
|
export function initializerFactory(
|
||||||
storageProvider: StorageProvider,
|
storageProvider: StorageProvider,
|
||||||
@@ -87,6 +81,7 @@ export function initializerFactory(
|
|||||||
_routingStackService: RoutingStackService,
|
_routingStackService: RoutingStackService,
|
||||||
defaultAuthService: DefaultAuthService,
|
defaultAuthService: DefaultAuthService,
|
||||||
paiaAuthService: PAIAAuthService,
|
paiaAuthService: PAIAAuthService,
|
||||||
|
dateFnsConfigurationService: DateFnsConfigurationService,
|
||||||
) {
|
) {
|
||||||
return async () => {
|
return async () => {
|
||||||
initLogger(logger);
|
initLogger(logger);
|
||||||
@@ -106,7 +101,10 @@ export function initializerFactory(
|
|||||||
// this language will be used as a fallback when a translation isn't found in the current language
|
// this language will be used as a fallback when a translation isn't found in the current language
|
||||||
translateService.setDefaultLang('en');
|
translateService.setDefaultLang('en');
|
||||||
translateService.use(languageCode);
|
translateService.use(languageCode);
|
||||||
moment.locale(languageCode);
|
const dateFnsLocale = await getDateFnsLocale(languageCode as SCLanguageCode, translateService);
|
||||||
|
setDefaultOptions({locale: dateFnsLocale});
|
||||||
|
dateFnsConfigurationService.setLocale(dateFnsLocale);
|
||||||
|
|
||||||
await defaultAuthService.init();
|
await defaultAuthService.init();
|
||||||
await paiaAuthService.init();
|
await paiaAuthService.init();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -142,6 +140,7 @@ export function createTranslateLoader(http: HttpClient) {
|
|||||||
ConfigModule,
|
ConfigModule,
|
||||||
DashboardModule,
|
DashboardModule,
|
||||||
DataModule,
|
DataModule,
|
||||||
|
DateFnsModule.forRoot(),
|
||||||
HebisModule,
|
HebisModule,
|
||||||
IonicModule.forRoot(),
|
IonicModule.forRoot(),
|
||||||
IonIconModule,
|
IonIconModule,
|
||||||
@@ -198,6 +197,7 @@ export function createTranslateLoader(http: HttpClient) {
|
|||||||
RoutingStackService,
|
RoutingStackService,
|
||||||
DefaultAuthService,
|
DefaultAuthService,
|
||||||
PAIAAuthService,
|
PAIAAuthService,
|
||||||
|
DateFnsConfigurationService,
|
||||||
],
|
],
|
||||||
useFactory: initializerFactory,
|
useFactory: initializerFactory,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {NgModule} from '@angular/core';
|
import {NgModule} from '@angular/core';
|
||||||
import {AssessmentListItemComponent} from './types/assessment/assessment-list-item.component';
|
import {AssessmentListItemComponent} from './types/assessment/assessment-list-item.component';
|
||||||
import {AssessmentBaseInfoComponent} from './types/assessment/assessment-base-info.component';
|
import {AssessmentBaseInfoComponent} from './types/assessment/assessment-base-info.component';
|
||||||
@@ -27,7 +26,6 @@ import {CourseOfStudyAssessmentComponent} from './types/course-of-study/course-o
|
|||||||
import {AssessmentsPageComponent} from './page/assessments-page.component';
|
import {AssessmentsPageComponent} from './page/assessments-page.component';
|
||||||
import {RouterModule} from '@angular/router';
|
import {RouterModule} from '@angular/router';
|
||||||
import {AuthGuardService} from '../auth/auth-guard.service';
|
import {AuthGuardService} from '../auth/auth-guard.service';
|
||||||
import {MomentModule} from 'ngx-moment';
|
|
||||||
import {AssessmentsListItemComponent} from './list/assessments-list-item.component';
|
import {AssessmentsListItemComponent} from './list/assessments-list-item.component';
|
||||||
import {AssessmentsDataListComponent} from './list/assessments-data-list.component';
|
import {AssessmentsDataListComponent} from './list/assessments-data-list.component';
|
||||||
import {AssessmentsDetailComponent} from './detail/assessments-detail.component';
|
import {AssessmentsDetailComponent} from './detail/assessments-detail.component';
|
||||||
@@ -37,6 +35,7 @@ import {ProtectedRoutes} from '../auth/protected.routes';
|
|||||||
import {AssessmentsTreeListComponent} from './list/assessments-tree-list.component';
|
import {AssessmentsTreeListComponent} from './list/assessments-tree-list.component';
|
||||||
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
||||||
import {UtilModule} from '../../util/util.module';
|
import {UtilModule} from '../../util/util.module';
|
||||||
|
import {FormatPurePipeModule, ParseIsoPipeModule} from 'ngx-date-fns';
|
||||||
|
|
||||||
const routes: ProtectedRoutes = [
|
const routes: ProtectedRoutes = [
|
||||||
{
|
{
|
||||||
@@ -75,8 +74,9 @@ const routes: ProtectedRoutes = [
|
|||||||
TranslateModule,
|
TranslateModule,
|
||||||
DataModule,
|
DataModule,
|
||||||
ThingTranslateModule,
|
ThingTranslateModule,
|
||||||
MomentModule,
|
|
||||||
UtilModule,
|
UtilModule,
|
||||||
|
ParseIsoPipeModule,
|
||||||
|
FormatPurePipeModule,
|
||||||
],
|
],
|
||||||
providers: [AssessmentsProvider],
|
providers: [AssessmentsProvider],
|
||||||
exports: [],
|
exports: [],
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {Component, DestroyRef, inject, Input, OnInit, ViewChild} from '@angular/
|
|||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {AssessmentsProvider} from '../assessments.provider';
|
import {AssessmentsProvider} from '../assessments.provider';
|
||||||
import {DataDetailComponent, ExternalDataLoadEvent} from '../../data/detail/data-detail.component';
|
import {DataDetailComponent, ExternalDataLoadEvent} from '../../data/detail/data-detail.component';
|
||||||
import {NavController, ViewWillEnter} from '@ionic/angular';
|
import {NavController} from '@ionic/angular';
|
||||||
import {DataRoutingService} from '../../data/data-routing.service';
|
import {DataRoutingService} from '../../data/data-routing.service';
|
||||||
import {SCAssessment} from '@openstapps/core';
|
import {SCAssessment} from '@openstapps/core';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
@@ -27,7 +27,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
|||||||
templateUrl: 'assessments-detail.html',
|
templateUrl: 'assessments-detail.html',
|
||||||
styleUrls: ['assessments-detail.scss'],
|
styleUrls: ['assessments-detail.scss'],
|
||||||
})
|
})
|
||||||
export class AssessmentsDetailComponent implements ViewWillEnter, OnInit {
|
export class AssessmentsDetailComponent implements OnInit {
|
||||||
destroy$ = inject(DestroyRef);
|
destroy$ = inject(DestroyRef);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -67,8 +67,4 @@ export class AssessmentsDetailComponent implements ViewWillEnter, OnInit {
|
|||||||
event.resolve(this.item);
|
event.resolve(this.item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async ionViewWillEnter() {
|
|
||||||
await this.detailComponent.ionViewWillEnter();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export class AssessmentsSimpleDataListComponent implements OnInit {
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
||||||
},
|
},
|
||||||
|
state: {item: thing},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ export class AssessmentsPageComponent implements OnInit, AfterViewInit {
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
||||||
},
|
},
|
||||||
|
state: {item: thing},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2 class="name">{{ 'name' | thingTranslate : item }} {{ item.date ? (item.date | amDateFormat) : '' }}</h2>
|
<h2 class="name">
|
||||||
|
{{ 'name' | thingTranslate : item }} {{ item.date ? (item.date | dfnsParseIso | dfnsFormatPure : 'Pp') :
|
||||||
|
'' }}
|
||||||
|
</h2>
|
||||||
<assessment-base-info [item]="item"></assessment-base-info>
|
<assessment-base-info [item]="item"></assessment-base-info>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {NgModule} from '@angular/core';
|
import {NgModule} from '@angular/core';
|
||||||
import {ScheduleSyncService} from './schedule/schedule-sync.service';
|
import {ScheduleSyncService} from './schedule/schedule-sync.service';
|
||||||
import {DateFormatPipe, DurationPipe} from 'ngx-moment';
|
|
||||||
import {CalendarModule} from '../calendar/calendar.module';
|
import {CalendarModule} from '../calendar/calendar.module';
|
||||||
import {ScheduleProvider} from '../calendar/schedule.provider';
|
import {ScheduleProvider} from '../calendar/schedule.provider';
|
||||||
import {StorageProvider} from '../storage/storage.provider';
|
import {StorageProvider} from '../storage/storage.provider';
|
||||||
@@ -27,13 +25,6 @@ import {CalendarService} from '../calendar/calendar.service';
|
|||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [],
|
declarations: [],
|
||||||
imports: [CalendarModule],
|
imports: [CalendarModule],
|
||||||
providers: [
|
providers: [ScheduleProvider, StorageProvider, CalendarService, ScheduleSyncService],
|
||||||
DurationPipe,
|
|
||||||
DateFormatPipe,
|
|
||||||
ScheduleProvider,
|
|
||||||
StorageProvider,
|
|
||||||
CalendarService,
|
|
||||||
ScheduleSyncService,
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
export class BackgroundModule {}
|
export class BackgroundModule {}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import {
|
|||||||
import {SCDateSeries, SCThingType, SCUuid} from '@openstapps/core';
|
import {SCDateSeries, SCThingType, SCUuid} from '@openstapps/core';
|
||||||
import {LocalNotifications} from '@capacitor/local-notifications';
|
import {LocalNotifications} from '@capacitor/local-notifications';
|
||||||
import {ThingTranslateService} from '../../../translation/thing-translate.service';
|
import {ThingTranslateService} from '../../../translation/thing-translate.service';
|
||||||
import {DateFormatPipe, DurationPipe} from 'ngx-moment';
|
|
||||||
import {BackgroundFetch} from '@transistorsoft/capacitor-background-fetch';
|
import {BackgroundFetch} from '@transistorsoft/capacitor-background-fetch';
|
||||||
import {StorageProvider} from '../../storage/storage.provider';
|
import {StorageProvider} from '../../storage/storage.provider';
|
||||||
import {CalendarService} from '../../calendar/calendar.service';
|
import {CalendarService} from '../../calendar/calendar.service';
|
||||||
@@ -46,8 +45,6 @@ export class ScheduleSyncService {
|
|||||||
private scheduleProvider: ScheduleProvider,
|
private scheduleProvider: ScheduleProvider,
|
||||||
private storageProvider: StorageProvider,
|
private storageProvider: StorageProvider,
|
||||||
private translator: ThingTranslateService,
|
private translator: ThingTranslateService,
|
||||||
private dateFormatPipe: DateFormatPipe,
|
|
||||||
private durationFormatPipe: DurationPipe,
|
|
||||||
private calendar: CalendarService,
|
private calendar: CalendarService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -136,11 +133,7 @@ export class ScheduleSyncService {
|
|||||||
change =>
|
change =>
|
||||||
`${
|
`${
|
||||||
this.translator.translator.translatedPropertyNames<SCDateSeries>(SCThingType.DateSeries)?.[change]
|
this.translator.translator.translatedPropertyNames<SCDateSeries>(SCThingType.DateSeries)?.[change]
|
||||||
}: ${formatRelevantKeys[change](
|
}: ${formatRelevantKeys[change](changes.new[change] as never)}`,
|
||||||
changes.new[change] as never,
|
|
||||||
this.dateFormatPipe,
|
|
||||||
this.durationFormatPipe,
|
|
||||||
)}`,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import {
|
|||||||
toICal,
|
toICal,
|
||||||
toICalUpdates,
|
toICalUpdates,
|
||||||
} from './ical/ical';
|
} from './ical/ical';
|
||||||
import moment from 'moment';
|
|
||||||
import {Share} from '@capacitor/share';
|
import {Share} from '@capacitor/share';
|
||||||
import {Directory, Encoding, Filesystem} from '@capacitor/filesystem';
|
import {Directory, Encoding, Filesystem} from '@capacitor/filesystem';
|
||||||
import {Device} from '@capacitor/device';
|
import {Device} from '@capacitor/device';
|
||||||
@@ -44,8 +43,6 @@ interface ICalInfo {
|
|||||||
styleUrls: ['add-event-review-modal.scss'],
|
styleUrls: ['add-event-review-modal.scss'],
|
||||||
})
|
})
|
||||||
export class AddEventReviewModalComponent implements OnInit {
|
export class AddEventReviewModalComponent implements OnInit {
|
||||||
moment = moment;
|
|
||||||
|
|
||||||
@Input() dismissAction: () => void;
|
@Input() dismissAction: () => void;
|
||||||
|
|
||||||
@Input() dateSeries: SCDateSeries[];
|
@Input() dateSeries: SCDateSeries[];
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<s *ngIf="iCalEvent.cancelled; else date"
|
<s *ngIf="iCalEvent.cancelled; else date"
|
||||||
><ng-container [ngTemplateOutlet]="date"></ng-container>
|
><ng-container [ngTemplateOutlet]="date"></ng-container>
|
||||||
</s>
|
</s>
|
||||||
<ng-template #date> {{ moment(iCalEvent.start) | amDateFormat : 'll, HH:mm' }} </ng-template>
|
<ng-template #date> {{ iCalEvent.start | dfnsParseIso | dfnsFormatPure : 'PPPp' }} </ng-template>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
<ion-note *ngIf="iCalEvent.rrule">
|
<ion-note *ngIf="iCalEvent.rrule">
|
||||||
{{ iCalEvent.rrule.interval }} {{ iCalEvent.rrule.freq | sentencecase }}
|
{{ iCalEvent.rrule.interval }} {{ iCalEvent.rrule.freq | sentencecase }}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {NgModule} from '@angular/core';
|
import {NgModule} from '@angular/core';
|
||||||
import {AddEventReviewModalComponent} from './add-event-review-modal.component';
|
import {AddEventReviewModalComponent} from './add-event-review-modal.component';
|
||||||
import {Calendar} from '@awesome-cordova-plugins/calendar/ngx';
|
import {Calendar} from '@awesome-cordova-plugins/calendar/ngx';
|
||||||
@@ -23,9 +22,9 @@ import {TranslateModule} from '@ngx-translate/core';
|
|||||||
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {MomentModule} from 'ngx-moment';
|
|
||||||
import {UtilModule} from '../../util/util.module';
|
import {UtilModule} from '../../util/util.module';
|
||||||
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
||||||
|
import {FormatPurePipeModule, ParseIsoPipeModule} from 'ngx-date-fns';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [AddEventReviewModalComponent],
|
declarations: [AddEventReviewModalComponent],
|
||||||
@@ -36,8 +35,9 @@ import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
|||||||
IonIconModule,
|
IonIconModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
MomentModule,
|
|
||||||
UtilModule,
|
UtilModule,
|
||||||
|
ParseIsoPipeModule,
|
||||||
|
FormatPurePipeModule,
|
||||||
],
|
],
|
||||||
exports: [],
|
exports: [],
|
||||||
providers: [Calendar, CalendarService, ScheduleProvider],
|
providers: [Calendar, CalendarService, ScheduleProvider],
|
||||||
|
|||||||
@@ -16,17 +16,18 @@
|
|||||||
import {Calendar} from '@awesome-cordova-plugins/calendar/ngx';
|
import {Calendar} from '@awesome-cordova-plugins/calendar/ngx';
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {ICalEvent} from './ical/ical';
|
import {ICalEvent} from './ical/ical';
|
||||||
import moment, {duration, Moment, unitOfTime} from 'moment';
|
|
||||||
import {Dialog} from '@capacitor/dialog';
|
import {Dialog} from '@capacitor/dialog';
|
||||||
import {CalendarInfo} from './calendar-info';
|
import {CalendarInfo} from './calendar-info';
|
||||||
import {Subject} from 'rxjs';
|
import {Subject} from 'rxjs';
|
||||||
import {ConfigProvider} from '../config/config.provider';
|
import {ConfigProvider} from '../config/config.provider';
|
||||||
|
import {add, differenceInDays, parseISO, startOfToday} from 'date-fns';
|
||||||
|
import {parse as parseISODuration} from 'duration-fns';
|
||||||
|
|
||||||
const RECURRENCE_PATTERNS: Partial<Record<unitOfTime.Diff, string | undefined>> = {
|
const RECURRENCE_PATTERNS: Partial<Record<keyof Duration, string | undefined>> = {
|
||||||
year: 'yearly',
|
years: 'yearly',
|
||||||
month: 'monthly',
|
months: 'monthly',
|
||||||
week: 'weekly',
|
weeks: 'weekly',
|
||||||
day: 'daily',
|
days: 'daily',
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -85,7 +86,7 @@ export class CalendarService {
|
|||||||
iCalEvent.geo,
|
iCalEvent.geo,
|
||||||
iCalEvent.description,
|
iCalEvent.description,
|
||||||
new Date(start),
|
new Date(start),
|
||||||
moment(start).add(duration(iCalEvent.duration)).toDate(),
|
add(parseISO(start), parseISODuration(iCalEvent.duration!)),
|
||||||
{
|
{
|
||||||
id: `${iCalEvent.uuid}-${start}`,
|
id: `${iCalEvent.uuid}-${start}`,
|
||||||
url: iCalEvent.url,
|
url: iCalEvent.url,
|
||||||
@@ -107,8 +108,8 @@ export class CalendarService {
|
|||||||
* Emit the calendar index corresponding to the input date.
|
* Emit the calendar index corresponding to the input date.
|
||||||
* @param date Moment - date the calendar should go to
|
* @param date Moment - date the calendar should go to
|
||||||
*/
|
*/
|
||||||
emitGoToDate(date: Moment) {
|
emitGoToDate(date: Date) {
|
||||||
const index = date.diff(moment().startOf('day'), 'days');
|
const index = differenceInDays(date, startOfToday());
|
||||||
this.goToDate.next(index);
|
this.goToDate.next(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,61 +13,59 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {findRRules, RRule} from './ical';
|
import {findRRules, RRule} from './ical';
|
||||||
import moment, {unitOfTime} from 'moment';
|
|
||||||
import {SCISO8601Date} from '@openstapps/core';
|
import {SCISO8601Date} from '@openstapps/core';
|
||||||
import {shuffle} from '@openstapps/collection-utils';
|
import {shuffle} from '@openstapps/collection-utils';
|
||||||
|
import {add, addWeeks, formatISO, isEqual, parseISO} from 'date-fns';
|
||||||
|
import {normalize} from 'duration-fns';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function expandRRule(rule: RRule): SCISO8601Date[] {
|
function expandRRule(rule: RRule): SCISO8601Date[] {
|
||||||
const initial = moment(rule.from);
|
const initial = parseISO(rule.from);
|
||||||
const interval = rule.interval ?? 1;
|
const interval = rule.interval ?? 1;
|
||||||
|
const dates = [initial];
|
||||||
|
while (!isEqual(dates.at(-1)!, parseISO(rule.until))) {
|
||||||
|
dates.push(add(dates.at(-1)!, normalize({[rule.freq ?? 'days']: interval}, dates.at(-1))));
|
||||||
|
}
|
||||||
|
|
||||||
return shuffle(
|
return shuffle(dates.map(date => formatISO(date)));
|
||||||
Array.from({
|
|
||||||
length: Math.floor(moment(rule.until).diff(initial, rule.freq, true) / interval) + 1,
|
|
||||||
}).map((_, i) =>
|
|
||||||
initial
|
|
||||||
.clone()
|
|
||||||
.add(interval * i, rule.freq ?? 'day')
|
|
||||||
.toISOString(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('iCal', () => {
|
describe('iCal', () => {
|
||||||
it('should find simple recurrence patterns', () => {
|
for (const freq of ['days', 'weeks', 'months', 'years'] as const) {
|
||||||
for (const freq of ['day', 'week', 'month', 'year'] as unitOfTime.Diff[]) {
|
for (const interval of [1, 2, 3]) {
|
||||||
for (const interval of [1, 2, 3]) {
|
it(`should find ${interval} ${freq} recurrence patterns`, () => {
|
||||||
const pattern: RRule = {
|
const pattern: RRule = {
|
||||||
freq: freq,
|
freq: freq,
|
||||||
interval: interval,
|
interval: interval,
|
||||||
from: moment('2021-09-01T10:00').toISOString(),
|
from: formatISO(parseISO('2021-09-01T10:00Z')),
|
||||||
until: moment('2021-09-01T10:00')
|
until: formatISO(
|
||||||
.add(4 * interval, freq)
|
add(parseISO('2021-09-01T10:00Z'), normalize({[freq]: 4 * interval}, '2021-09-01')),
|
||||||
.toISOString(),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log(expandRRule(pattern));
|
||||||
|
|
||||||
expect(findRRules(expandRRule(pattern))).toEqual([pattern]);
|
expect(findRRules(expandRRule(pattern))).toEqual([pattern]);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
it('should find missing recurrence patterns', () => {
|
it('should find missing recurrence patterns', () => {
|
||||||
const pattern: SCISO8601Date = moment('2021-09-01T10:00').toISOString();
|
const pattern: SCISO8601Date = formatISO(parseISO('2021-09-01T10:00'));
|
||||||
|
|
||||||
expect(findRRules([pattern])).toEqual([pattern]);
|
expect(findRRules([pattern])).toEqual([pattern]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should find mixed recurrence patterns', () => {
|
it('should find mixed recurrence patterns', () => {
|
||||||
const singlePattern: SCISO8601Date = moment('2021-09-01T09:00').toISOString();
|
const singlePattern: SCISO8601Date = formatISO(parseISO('2021-09-01T09:00'));
|
||||||
|
|
||||||
const weeklyPattern: RRule = {
|
const weeklyPattern: RRule = {
|
||||||
freq: 'week',
|
freq: 'weeks',
|
||||||
interval: 1,
|
interval: 1,
|
||||||
from: moment('2021-09-03T10:00').toISOString(),
|
from: formatISO(parseISO('2021-09-03T10:00')),
|
||||||
until: moment('2021-09-03T10:00').add(4, 'weeks').toISOString(),
|
until: formatISO(addWeeks(parseISO('2021-09-03T10:00'), 4)),
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(findRRules(shuffle([singlePattern, ...expandRRule(weeklyPattern)]))).toEqual([
|
expect(findRRules(shuffle([singlePattern, ...expandRRule(weeklyPattern)]))).toEqual([
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ import {
|
|||||||
SCThingWithCategories,
|
SCThingWithCategories,
|
||||||
SCUuid,
|
SCUuid,
|
||||||
} from '@openstapps/core';
|
} from '@openstapps/core';
|
||||||
import moment, {unitOfTime} from 'moment';
|
|
||||||
import {minBy, mapValues} from '@openstapps/collection-utils';
|
import {minBy, mapValues} from '@openstapps/collection-utils';
|
||||||
|
import type {Duration} from 'date-fns';
|
||||||
|
import {formatISO, intervalToDuration, parseISO} from 'date-fns';
|
||||||
|
import {toUnit} from 'duration-fns';
|
||||||
|
|
||||||
export interface ICalEvent {
|
export interface ICalEvent {
|
||||||
name?: string;
|
name?: string;
|
||||||
@@ -55,19 +57,25 @@ export type ICalLike = ICalKeyValuePair[];
|
|||||||
function timeDistance(
|
function timeDistance(
|
||||||
current: SCISO8601Date,
|
current: SCISO8601Date,
|
||||||
next: SCISO8601Date | undefined,
|
next: SCISO8601Date | undefined,
|
||||||
recurrence: unitOfTime.Diff,
|
recurrence: keyof Duration,
|
||||||
): number | undefined {
|
): number | undefined {
|
||||||
if (!next) {
|
if (!next) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const diff = moment(next).diff(moment(current), recurrence, true);
|
const diff = toUnit(
|
||||||
|
intervalToDuration({
|
||||||
|
start: parseISO(next),
|
||||||
|
end: parseISO(current),
|
||||||
|
}),
|
||||||
|
recurrence,
|
||||||
|
);
|
||||||
|
|
||||||
return Math.floor(diff) === diff ? diff : undefined;
|
return Math.floor(diff) === diff ? diff : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RRule {
|
export interface RRule {
|
||||||
freq: unitOfTime.Diff; // 'SECONDLY' | 'HOURLY' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
|
freq: keyof Duration;
|
||||||
interval: number;
|
interval: number;
|
||||||
from: SCISO8601Date;
|
from: SCISO8601Date;
|
||||||
until: SCISO8601Date;
|
until: SCISO8601Date;
|
||||||
@@ -97,7 +105,7 @@ export function mergeRRules(rules: Array<RRule | SCISO8601Date>, allowExceptions
|
|||||||
* Find RRules in a list of dates
|
* Find RRules in a list of dates
|
||||||
*/
|
*/
|
||||||
export function findRRules(dates: SCISO8601Date[]): Array<RRule | SCISO8601Date> {
|
export function findRRules(dates: SCISO8601Date[]): Array<RRule | SCISO8601Date> {
|
||||||
const sorted = dates.sort((a, b) => moment(a).unix() - moment(b).unix());
|
const sorted = dates.sort();
|
||||||
|
|
||||||
const output: Optional<RRule, 'freq'>[] = [
|
const output: Optional<RRule, 'freq'>[] = [
|
||||||
{
|
{
|
||||||
@@ -112,7 +120,9 @@ export function findRRules(dates: SCISO8601Date[]): Array<RRule | SCISO8601Date>
|
|||||||
const next = sorted[i + 1] as SCISO8601Date | undefined;
|
const next = sorted[i + 1] as SCISO8601Date | undefined;
|
||||||
const element = output.at(-1);
|
const element = output.at(-1);
|
||||||
|
|
||||||
const units: unitOfTime.Diff[] = element?.freq ? [element.freq] : ['day', 'week', 'month', 'year'];
|
const units: Array<keyof Duration> = element?.freq
|
||||||
|
? [element.freq]
|
||||||
|
: ['days', 'weeks', 'months', 'years'];
|
||||||
const freq = minBy(
|
const freq = minBy(
|
||||||
units.map(recurrence => ({
|
units.map(recurrence => ({
|
||||||
recurrence: recurrence,
|
recurrence: recurrence,
|
||||||
@@ -226,14 +236,14 @@ export function toICalUpdates(dateSeries: SCDateSeries, translator: SCThingTrans
|
|||||||
export function iso8601ToICalDateTime<T extends SCISO8601Date | undefined>(
|
export function iso8601ToICalDateTime<T extends SCISO8601Date | undefined>(
|
||||||
date: T,
|
date: T,
|
||||||
): T extends SCISO8601Date ? string : undefined {
|
): T extends SCISO8601Date ? string : undefined {
|
||||||
return (date ? `${moment(date).utc().format('YYYYMMDDTHHmmss')}Z` : undefined) as never;
|
return (date ? formatISO(parseISO(date), {format: 'basic'}) : undefined) as never;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert an ISO8601 date to a string in the format YYYYMMDD
|
* Convert an ISO8601 date to a string in the format YYYYMMDD
|
||||||
*/
|
*/
|
||||||
export function iso8601ToICalDate(date: SCISO8601Date): string {
|
export function iso8601ToICalDate(date: SCISO8601Date): string {
|
||||||
return `${moment(date).utc().format('YYYYMMDD')}`;
|
return formatISO(parseISO(date), {format: 'basic', representation: 'date'});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,11 +276,11 @@ export function normalizeICalDates(iCal: ICalEvent): ICalEvent {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const REPEAT_FREQUENCIES: Partial<Record<unitOfTime.Diff, string>> = {
|
const REPEAT_FREQUENCIES: Partial<Record<keyof Duration, string>> = {
|
||||||
day: 'DAILY',
|
days: 'DAILY',
|
||||||
week: 'WEEKLY',
|
weeks: 'WEEKLY',
|
||||||
month: 'MONTHLY',
|
months: 'MONTHLY',
|
||||||
year: 'YEARLY',
|
years: 'YEARLY',
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,7 +318,7 @@ export function serializeICalEvent(iCal: ICalEvent): ICalLike {
|
|||||||
'BEGIN:VEVENT',
|
'BEGIN:VEVENT',
|
||||||
`DTSTART:${normalized.start}`,
|
`DTSTART:${normalized.start}`,
|
||||||
`DURATION:${normalized.duration}`,
|
`DURATION:${normalized.duration}`,
|
||||||
`DTSTAMP:${moment().utc().format('YYYYMMDDTHHmmss')}Z`,
|
`DTSTAMP:${formatISO(Date.now(), {format: 'basic'})}`,
|
||||||
`UID:${normalized.uuid}`,
|
`UID:${normalized.uuid}`,
|
||||||
`RECURRENCE-ID:${normalized.recurrenceId}`,
|
`RECURRENCE-ID:${normalized.recurrenceId}`,
|
||||||
`CATEGORIES:${normalized.categories?.join(',')}`,
|
`CATEGORIES:${normalized.categories?.join(',')}`,
|
||||||
|
|||||||
@@ -26,9 +26,10 @@ import {
|
|||||||
import {BehaviorSubject, Observable} from 'rxjs';
|
import {BehaviorSubject, Observable} from 'rxjs';
|
||||||
import {DataProvider} from '../data/data.provider';
|
import {DataProvider} from '../data/data.provider';
|
||||||
import {map} from 'rxjs/operators';
|
import {map} from 'rxjs/operators';
|
||||||
import {DateFormatPipe, DurationPipe} from 'ngx-moment';
|
|
||||||
import {pick} from '@openstapps/collection-utils';
|
import {pick} from '@openstapps/collection-utils';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
import {format, formatDuration, parseISO} from 'date-fns';
|
||||||
|
import {parse as parseISODuration} from 'duration-fns';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -48,17 +49,13 @@ export const dateSeriesRelevantKeys: Array<DateSeriesRelevantKeys> = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const formatRelevantKeys: {
|
export const formatRelevantKeys: {
|
||||||
[key in DateSeriesRelevantKeys]: (
|
[key in DateSeriesRelevantKeys]: (value: SCDateSeries[key]) => string;
|
||||||
value: SCDateSeries[key],
|
|
||||||
dateFormatter: DateFormatPipe,
|
|
||||||
durationFormatter: DurationPipe,
|
|
||||||
) => string;
|
|
||||||
} = {
|
} = {
|
||||||
uid: value => value,
|
uid: value => value,
|
||||||
dates: (value, dateFormatter) => `[${value.map(it => dateFormatter.transform(it)).join(', ')}]`,
|
dates: value => `[${value.map(it => format(parseISO(it), 'PPp')).join(', ')}]`,
|
||||||
exceptions: (value, dateFormatter) => `[${value?.map(it => dateFormatter.transform(it)).join(', ') ?? ''}]`,
|
exceptions: value => `[${value?.map(it => format(parseISO(it), 'PPp')).join(', ') ?? ''}]`,
|
||||||
repeatFrequency: (value, _, durationFormatter) => durationFormatter.transform(value),
|
repeatFrequency: value => (value ? formatDuration(parseISODuration(value)) : ''),
|
||||||
duration: (value, _, durationFormatter) => durationFormatter.transform(value),
|
duration: value => formatDuration(parseISODuration(value)),
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DateSeriesRelevantData = Pick<SCDateSeries, DateSeriesRelevantKeys>;
|
export type DateSeriesRelevantData = Pick<SCDateSeries, DateSeriesRelevantKeys>;
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {Router, ActivatedRoute} from '@angular/router';
|
import {Router, ActivatedRoute} from '@angular/router';
|
||||||
import {SCCatalog, SCSemester} from '@openstapps/core';
|
import {SCCatalog, SCSemester} from '@openstapps/core';
|
||||||
import moment from 'moment';
|
|
||||||
import {CatalogProvider} from './catalog.provider';
|
import {CatalogProvider} from './catalog.provider';
|
||||||
import {NGXLogger} from 'ngx-logger';
|
import {NGXLogger} from 'ngx-logger';
|
||||||
import {Location} from '@angular/common';
|
import {Location} from '@angular/common';
|
||||||
import {DataRoutingService} from '../data/data-routing.service';
|
import {DataRoutingService} from '../data/data-routing.service';
|
||||||
|
import {formatISO, startOfToday} from 'date-fns';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -65,7 +65,7 @@ export class CatalogComponent implements OnInit {
|
|||||||
.itemSelectListener()
|
.itemSelectListener()
|
||||||
.pipe(takeUntilDestroyed())
|
.pipe(takeUntilDestroyed())
|
||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
void this.router.navigate(['data-detail', item.uid]);
|
void this.router.navigate(['data-detail', item.uid], {state: {item}});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ export class CatalogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fetchSemesters(): Promise<void> {
|
async fetchSemesters(): Promise<void> {
|
||||||
const today = moment().startOf('day').toISOString();
|
const today = formatISO(startOfToday());
|
||||||
const semesters = await this.catalogProvider.getRelevantSemesters();
|
const semesters = await this.catalogProvider.getRelevantSemesters();
|
||||||
const currentSemester = semesters.find(
|
const currentSemester = semesters.find(
|
||||||
semester => semester.startDate <= today && semester.endDate > today,
|
semester => semester.startDate <= today && semester.endDate > today,
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import {FormsModule} from '@angular/forms';
|
|||||||
import {RouterModule, Routes} from '@angular/router';
|
import {RouterModule, Routes} from '@angular/router';
|
||||||
import {IonicModule} from '@ionic/angular';
|
import {IonicModule} from '@ionic/angular';
|
||||||
import {TranslateModule} from '@ngx-translate/core';
|
import {TranslateModule} from '@ngx-translate/core';
|
||||||
import {MomentModule} from 'ngx-moment';
|
|
||||||
import {DataModule} from '../data/data.module';
|
import {DataModule} from '../data/data.module';
|
||||||
import {SettingsProvider} from '../settings/settings.provider';
|
import {SettingsProvider} from '../settings/settings.provider';
|
||||||
import {CatalogComponent} from './catalog.component';
|
import {CatalogComponent} from './catalog.component';
|
||||||
@@ -42,7 +41,6 @@ const catalogRoutes: Routes = [
|
|||||||
RouterModule.forChild(catalogRoutes),
|
RouterModule.forChild(catalogRoutes),
|
||||||
IonIconModule,
|
IonIconModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
MomentModule,
|
|
||||||
DataModule,
|
DataModule,
|
||||||
UtilModule,
|
UtilModule,
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -19,20 +19,21 @@
|
|||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
<div #schedule class="schedule">
|
<div #schedule class="schedule">
|
||||||
<a [routerLink]="['/schedule/recurring']">
|
<a [routerLink]="['/schedule/week-overview']">
|
||||||
<ion-icon size="40" weight="300" name="grid_view"></ion-icon>
|
<ion-icon size="36" weight="300" name="calendar_month"></ion-icon>
|
||||||
<ion-label>{{ 'schedule.recurring' | translate }}</ion-label>
|
<ion-label [innerHTML]="'schedule.recurring' | translate"></ion-label>
|
||||||
</a>
|
</a>
|
||||||
<!-- Avoid structural directives here, they might interfere with the collapse animation -->
|
<!-- Avoid structural directives here, they might interfere with the collapse animation -->
|
||||||
<a
|
<a
|
||||||
[routerLink]="nextEvent?.event ? ['/data-detail', nextEvent!.event.uid] : ['/schedule/recurring']"
|
[routerLink]="nextEvent ? ['/data-detail', nextEvent!.uid] : ['/schedule/calendar']"
|
||||||
|
[state]="{item: nextEvent}"
|
||||||
class="schedule-item-button"
|
class="schedule-item-button"
|
||||||
>
|
>
|
||||||
<ion-label>{{ 'dashboard.schedule.title' | translate }}</ion-label>
|
<ion-label>{{ 'dashboard.schedule.title' | translate }}</ion-label>
|
||||||
<ion-label>
|
<ion-label>
|
||||||
{{
|
{{
|
||||||
nextEvent?.event
|
nextEvent
|
||||||
? (nextEvent!.dates | nextDateInList | amDateFormat : 'll, HH:mm')
|
? (nextEvent!.dates.sort().at(-1) | dfnsParseIso | dfnsFormatRelativePure : (now | async))
|
||||||
: ('dashboard.schedule.noEvent' | translate)
|
: ('dashboard.schedule.noEvent' | translate)
|
||||||
}}
|
}}
|
||||||
</ion-label>
|
</ion-label>
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ ion-content {
|
|||||||
ion-label {
|
ion-label {
|
||||||
font-size: var(--font-size-xxs);
|
font-size: var(--font-size-xxs);
|
||||||
font-weight: var(--font-weight-semi-bold);
|
font-weight: var(--font-weight-semi-bold);
|
||||||
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover ::ng-deep stapps-icon {
|
&:hover ::ng-deep stapps-icon {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
import {Component, DestroyRef, ElementRef, inject, NgZone, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
import {Component, DestroyRef, ElementRef, inject, NgZone, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {Location} from '@angular/common';
|
import {Location} from '@angular/common';
|
||||||
import moment from 'moment';
|
import {timer} from 'rxjs';
|
||||||
import {SCDateSeries, SCUuid} from '@openstapps/core';
|
import {SCDateSeries, SCUuid} from '@openstapps/core';
|
||||||
import {SplashScreen} from '@capacitor/splash-screen';
|
import {SplashScreen} from '@capacitor/splash-screen';
|
||||||
import {DataRoutingService} from '../data/data-routing.service';
|
import {DataRoutingService} from '../data/data-routing.service';
|
||||||
@@ -24,6 +24,10 @@ import {AnimationController, IonContent} from '@ionic/angular';
|
|||||||
import {DashboardCollapse} from './dashboard-collapse';
|
import {DashboardCollapse} from './dashboard-collapse';
|
||||||
import {BreakpointObserver} from '@angular/cdk/layout';
|
import {BreakpointObserver} from '@angular/cdk/layout';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
import {formatISO, minutesToMilliseconds, startOfWeek} from 'date-fns';
|
||||||
|
import {map} from 'rxjs/operators';
|
||||||
|
|
||||||
|
// const scrollTimeline = new ScrollTimeline();
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dashboard',
|
selector: 'app-dashboard',
|
||||||
@@ -63,6 +67,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
destroy$ = inject(DestroyRef);
|
destroy$ = inject(DestroyRef);
|
||||||
|
|
||||||
|
now = timer(0, minutesToMilliseconds(1)).pipe(map(() => Date.now()));
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly dataRoutingService: DataRoutingService,
|
private readonly dataRoutingService: DataRoutingService,
|
||||||
private scheduleProvider: ScheduleProvider,
|
private scheduleProvider: ScheduleProvider,
|
||||||
@@ -76,7 +82,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
.itemSelectListener()
|
.itemSelectListener()
|
||||||
.pipe(takeUntilDestroyed())
|
.pipe(takeUntilDestroyed())
|
||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
void this.router.navigate(['data-detail', item.uid]);
|
void this.router.navigate(['data-detail', item.uid], {state: {item}});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +114,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
const dataSeries = await this.scheduleProvider.getDateSeries(
|
const dataSeries = await this.scheduleProvider.getDateSeries(
|
||||||
this.eventUuids,
|
this.eventUuids,
|
||||||
undefined,
|
undefined,
|
||||||
moment(moment.now()).startOf('week').toISOString(),
|
formatISO(startOfWeek(Date.now())),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.nextEvent = dataSeries.dates
|
this.nextEvent = dataSeries.dates
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import {RouterModule, Routes} from '@angular/router';
|
|||||||
import {IonicModule} from '@ionic/angular';
|
import {IonicModule} from '@ionic/angular';
|
||||||
import {SwiperModule} from 'swiper/angular';
|
import {SwiperModule} from 'swiper/angular';
|
||||||
import {TranslateModule, TranslatePipe} from '@ngx-translate/core';
|
import {TranslateModule, TranslatePipe} from '@ngx-translate/core';
|
||||||
import {MomentModule} from 'ngx-moment';
|
|
||||||
import {DataModule} from '../data/data.module';
|
import {DataModule} from '../data/data.module';
|
||||||
import {SettingsProvider} from '../settings/settings.provider';
|
import {SettingsProvider} from '../settings/settings.provider';
|
||||||
import {DashboardComponent} from './dashboard.component';
|
import {DashboardComponent} from './dashboard.component';
|
||||||
@@ -32,6 +31,7 @@ import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
|||||||
import {UtilModule} from '../../util/util.module';
|
import {UtilModule} from '../../util/util.module';
|
||||||
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
||||||
import {NewsModule} from '../news/news.module';
|
import {NewsModule} from '../news/news.module';
|
||||||
|
import {FormatRelativePurePipeModule, ParseIsoPipeModule} from 'ngx-date-fns';
|
||||||
|
|
||||||
const catalogRoutes: Routes = [
|
const catalogRoutes: Routes = [
|
||||||
{
|
{
|
||||||
@@ -59,12 +59,13 @@ const catalogRoutes: Routes = [
|
|||||||
TranslateModule.forChild(),
|
TranslateModule.forChild(),
|
||||||
RouterModule.forChild(catalogRoutes),
|
RouterModule.forChild(catalogRoutes),
|
||||||
CommonModule,
|
CommonModule,
|
||||||
MomentModule,
|
|
||||||
DataModule,
|
DataModule,
|
||||||
SwiperModule,
|
SwiperModule,
|
||||||
ThingTranslateModule.forChild(),
|
ThingTranslateModule.forChild(),
|
||||||
UtilModule,
|
UtilModule,
|
||||||
NewsModule,
|
NewsModule,
|
||||||
|
ParseIsoPipeModule,
|
||||||
|
FormatRelativePurePipeModule,
|
||||||
],
|
],
|
||||||
providers: [SettingsProvider, TranslatePipe],
|
providers: [SettingsProvider, TranslatePipe],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
<stapps-data-list-item
|
<stapps-data-list-item
|
||||||
*ngFor="let dish of dishes"
|
*ngFor="let dish of dishes"
|
||||||
[hideThumbnail]="true"
|
[hideThumbnail]="true"
|
||||||
[favoriteButton]="false"
|
|
||||||
[item]="dish"
|
[item]="dish"
|
||||||
appearance="square"
|
appearance="square"
|
||||||
></stapps-data-list-item>
|
></stapps-data-list-item>
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
|
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
|
||||||
import {SCDish, SCPlace, SCThings} from '@openstapps/core';
|
import {SCDish, SCPlace, SCThings} from '@openstapps/core';
|
||||||
import {PlaceMensaService} from '../../../data/types/place/special/mensa/place-mensa-service';
|
import {PlaceMensaService} from '../../../data/types/place/special/mensa/place-mensa-service';
|
||||||
import moment from 'moment';
|
|
||||||
import {fadeAnimation} from '../../fade.animation';
|
import {fadeAnimation} from '../../fade.animation';
|
||||||
|
import {isToday, parseISO} from 'date-fns';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a section with meals of the chosen mensa
|
* Shows a section with meals of the chosen mensa
|
||||||
@@ -38,10 +38,10 @@ export class MensaSectionContentComponent {
|
|||||||
@Input() set item(value: SCThings) {
|
@Input() set item(value: SCThings) {
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
this.dishes = this.mensaService.getAllDishes(value as SCPlace, 1).then(it => {
|
this.dishes = this.mensaService.getAllDishes(value as SCPlace, 1).then(it => {
|
||||||
const closestDayWithDishes = Object.keys(it)
|
const days = Object.entries(it);
|
||||||
.filter(key => it[key].length > 0)
|
console.assert(days.length <= 1);
|
||||||
.find(key => moment(key).isSame(moment(), 'day'));
|
console.assert(!days[0] || isToday(parseISO(days[0][0])));
|
||||||
return closestDayWithDishes ? it[closestDayWithDishes] : [];
|
return days[0]?.[1] ?? [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export class ActionChipListComponent {
|
|||||||
event:
|
event:
|
||||||
item.type === SCThingType.AcademicEvent ||
|
item.type === SCThingType.AcademicEvent ||
|
||||||
(item.type === SCThingType.DateSeries && (item as SCDateSeries).dates.length > 0),
|
(item.type === SCThingType.DateSeries && (item as SCDateSeries).dates.length > 0),
|
||||||
|
navigate: ('inPlace' in item && item.inPlace && 'geo' in item.inPlace) || 'geo' in item,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,5 +14,6 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<stapps-locate-action-chip *ngIf="applicable.locate" [item]="item"></stapps-locate-action-chip>
|
<stapps-locate-action-chip *ngIf="applicable.locate" [item]="item"></stapps-locate-action-chip>
|
||||||
|
<stapps-navigate-action-chip *ngIf="applicable.navigate" [item]="$any(item)"></stapps-navigate-action-chip>
|
||||||
<!-- Add Event Chip needs to load data and should be the last -->
|
<!-- Add Event Chip needs to load data and should be the last -->
|
||||||
<stapps-add-event-action-chip *ngIf="applicable.event" [item]="item"></stapps-add-event-action-chip>
|
<stapps-add-event-action-chip *ngIf="applicable.event" [item]="item"></stapps-add-event-action-chip>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 StApps
|
* Copyright (C) 2023 StApps
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the Free
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
* Software Foundation, version 3.
|
* Software Foundation, version 3.
|
||||||
@@ -13,19 +13,23 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, Input} from '@angular/core';
|
import {Component, Input} from '@angular/core';
|
||||||
import {SCPlace} from '@openstapps/core';
|
import {SCPlaceWithoutReferences, SCThings} from '@openstapps/core';
|
||||||
import {ModalController} from '@ionic/angular';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-map-single-modal',
|
selector: 'stapps-navigate-action-chip',
|
||||||
templateUrl: './map-single.html',
|
templateUrl: 'navigate-action-chip.html',
|
||||||
styleUrls: ['./map-single.scss'],
|
styleUrls: ['navigate-action-chip.scss'],
|
||||||
})
|
})
|
||||||
export class MapSingleModalComponent {
|
export class NavigateActionChipComponent {
|
||||||
/**
|
place: SCPlaceWithoutReferences;
|
||||||
* The item to be shown
|
|
||||||
*/
|
|
||||||
@Input() item: SCPlace;
|
|
||||||
|
|
||||||
constructor(readonly modalController: ModalController) {}
|
@Input({required: true}) set item(value: SCThings) {
|
||||||
|
if ('geo' in value) {
|
||||||
|
this.place = value;
|
||||||
|
} else if ('inPlace' in value && value.inPlace && 'geo' in value.inPlace) {
|
||||||
|
this.place = value.inPlace;
|
||||||
|
} else {
|
||||||
|
console.error('Invalid place', value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
~ Copyright (C) 2022 StApps
|
~ Copyright (C) 2023 StApps
|
||||||
~ This program is free software: you can redistribute it and/or modify it
|
~ This program is free software: you can redistribute it and/or modify it
|
||||||
~ under the terms of the GNU General Public License as published by the Free
|
~ under the terms of the GNU General Public License as published by the Free
|
||||||
~ Software Foundation, version 3.
|
~ Software Foundation, version 3.
|
||||||
@@ -12,15 +12,7 @@
|
|||||||
~ You should have received a copy of the GNU General Public License along with
|
~ You should have received a copy of the GNU General Public License along with
|
||||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
<ion-chip [color]="'primary'" [outline]="true" [geoNavigation]="place">
|
||||||
<ion-header translucent>
|
<ion-icon name="directions"></ion-icon>
|
||||||
<ion-toolbar color="primary" mode="ios">
|
<ion-label>{{'map.directions.TITLE' | translate}}</ion-label>
|
||||||
<ion-title>{{ 'map.modals.single.TITLE' | translate }}</ion-title>
|
</ion-chip>
|
||||||
<ion-buttons slot="end">
|
|
||||||
<ion-button (click)="modalController.dismiss()">{{ 'app.ui.CLOSE' | translate }}</ion-button>
|
|
||||||
</ion-buttons>
|
|
||||||
</ion-toolbar>
|
|
||||||
</ion-header>
|
|
||||||
<ion-content>
|
|
||||||
<stapps-data-detail-content [item]="$any(item)" [openAsModal]="true"></stapps-data-detail-content>
|
|
||||||
</ion-content>
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*!
|
||||||
* Copyright (C) 2021 StApps
|
* Copyright (C) 2023 StApps
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the Free
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
* Software Foundation, version 3.
|
* Software Foundation, version 3.
|
||||||
@@ -12,16 +12,3 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Pipe, PipeTransform} from '@angular/core';
|
|
||||||
import {Moment} from 'moment';
|
|
||||||
|
|
||||||
@Pipe({
|
|
||||||
name: 'dateFromIndex',
|
|
||||||
pure: true,
|
|
||||||
})
|
|
||||||
export class DateFromIndexPipe implements PipeTransform {
|
|
||||||
transform(index: number, baseline: Moment): Moment {
|
|
||||||
return baseline.clone().add(index, 'days');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
>
|
>
|
||||||
<ion-list-header>
|
<ion-list-header>
|
||||||
{{ frequency.children[0].item.repeatFrequency ? (frequency.children[0].item.repeatFrequency |
|
{{ frequency.children[0].item.repeatFrequency ? (frequency.children[0].item.repeatFrequency |
|
||||||
durationLocalized: true | sentencecase) : ('data.chips.add_events.popover.SINGLE' | translate |
|
dfnsParseDuration | dfnsFormatFrequencyPure | sentencecase) :
|
||||||
titlecase) }}
|
('data.chips.add_events.popover.SINGLE' | translate | titlecase) }}
|
||||||
</ion-list-header>
|
</ion-list-header>
|
||||||
</ion-checkbox>
|
</ion-checkbox>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
@@ -44,18 +44,19 @@
|
|||||||
>
|
>
|
||||||
<ng-container *ngIf="date.item.dates.length > 1; else single_event">
|
<ng-container *ngIf="date.item.dates.length > 1; else single_event">
|
||||||
<ion-text>
|
<ion-text>
|
||||||
{{ date.item.dates[0] | amDateFormat: 'dddd, LT' }} - {{ date.item.dates[0] | amAdd:
|
<b>{{ date.item.duration | dfnsParseDuration | dfnsFormatDurationPure }}</b>
|
||||||
date.item.duration | amDateFormat: 'LT' }}
|
{{ date.item.dates[0] | dfnsParseIso | dfnsFormatPure: 'EEEE, p' }}
|
||||||
</ion-text>
|
</ion-text>
|
||||||
<br />
|
<br />
|
||||||
<ion-text>
|
<ion-text>
|
||||||
{{ date.item.dates[0] | amDateFormat: 'LL' }} - {{ date.item.dates[date.item.dates.length - 1] |
|
{{ date.item.dates[0] | dfnsParseIso | dfnsFormatPure: 'PPP' }} - {{
|
||||||
amDateFormat: 'LL' }}
|
date.item.dates[date.item.dates.length - 1] | dfnsParseIso | dfnsFormatPure: 'PPP' }}
|
||||||
</ion-text>
|
</ion-text>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-template #single_event>
|
<ng-template #single_event>
|
||||||
<ion-text *ngIf="date.item.dates[0] as time; else noDates">
|
<ion-text *ngIf="date.item.dates[0] as time; else noDates">
|
||||||
{{ time | amDateFormat: 'LL, LT' }} - {{ time | amAdd: date.item.duration | amDateFormat: 'LT' }}
|
<b>{{ date.item.duration |dfnsParseDuration | dfnsFormatDurationPure}}</b>
|
||||||
|
{{ time | dfnsParseIso | dfnsFormatPure: 'PPPPp' }}
|
||||||
</ion-text>
|
</ion-text>
|
||||||
<ng-template #noDates>
|
<ng-template #noDates>
|
||||||
<ion-text color="danger">{{ 'data.chips.add_events.popover.DATA_ERROR' | translate }}</ion-text>
|
<ion-text color="danger">{{ 'data.chips.add_events.popover.DATA_ERROR' | translate }}</ion-text>
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import {FormsModule} from '@angular/forms';
|
|||||||
import {IonicModule, Platform} from '@ionic/angular';
|
import {IonicModule, Platform} from '@ionic/angular';
|
||||||
import {TranslateModule} from '@ngx-translate/core';
|
import {TranslateModule} from '@ngx-translate/core';
|
||||||
import {MarkdownModule} from 'ngx-markdown';
|
import {MarkdownModule} from 'ngx-markdown';
|
||||||
import {MomentModule} from 'ngx-moment';
|
|
||||||
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
||||||
import {MenuModule} from '../menu/menu.module';
|
import {MenuModule} from '../menu/menu.module';
|
||||||
import {ScheduleProvider} from '../calendar/schedule.provider';
|
import {ScheduleProvider} from '../calendar/schedule.provider';
|
||||||
@@ -102,6 +101,17 @@ import {StappsRatingComponent} from './elements/rating.component';
|
|||||||
import {DishCharacteristicsComponent} from './types/dish/dish-characteristics.component';
|
import {DishCharacteristicsComponent} from './types/dish/dish-characteristics.component';
|
||||||
import {SkeletonListComponent} from './list/skeleton-list.component';
|
import {SkeletonListComponent} from './list/skeleton-list.component';
|
||||||
import {CertificationsInDetailComponent} from './elements/certifications-in-detail.component';
|
import {CertificationsInDetailComponent} from './elements/certifications-in-detail.component';
|
||||||
|
import {GeoNavigationDirective} from '../map/geo-navigation.directive';
|
||||||
|
import {NavigateActionChipComponent} from './chips/data/navigate-action-chip.component';
|
||||||
|
import {
|
||||||
|
FormatDurationPurePipeModule,
|
||||||
|
FormatPurePipeModule,
|
||||||
|
FormatRelativeToNowPurePipeModule,
|
||||||
|
ParseIsoPipeModule,
|
||||||
|
} from 'ngx-date-fns';
|
||||||
|
import {ParseDurationPipe} from '../../translation/date-time/parse-duration.pipe';
|
||||||
|
import {DfnsFormatFrequencyPurePipe} from '../../translation/date-time/format-frequency.pipe';
|
||||||
|
import {DfnsFormatRelativeDatePurePipe} from '../../translation/date-time/format-relative-date.pipe';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module for handling data
|
* Module for handling data
|
||||||
@@ -110,6 +120,7 @@ import {CertificationsInDetailComponent} from './elements/certifications-in-deta
|
|||||||
declarations: [
|
declarations: [
|
||||||
ActionChipListComponent,
|
ActionChipListComponent,
|
||||||
AddEventActionChipComponent,
|
AddEventActionChipComponent,
|
||||||
|
NavigateActionChipComponent,
|
||||||
EditEventSelectionComponent,
|
EditEventSelectionComponent,
|
||||||
AddressDetailComponent,
|
AddressDetailComponent,
|
||||||
CatalogDetailContentComponent,
|
CatalogDetailContentComponent,
|
||||||
@@ -184,16 +195,19 @@ import {CertificationsInDetailComponent} from './elements/certifications-in-deta
|
|||||||
MarkdownModule.forRoot(),
|
MarkdownModule.forRoot(),
|
||||||
MenuModule,
|
MenuModule,
|
||||||
IonIconModule,
|
IonIconModule,
|
||||||
MomentModule.forRoot({
|
|
||||||
relativeTimeThresholdOptions: {
|
|
||||||
m: 59,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
ScrollingModule,
|
ScrollingModule,
|
||||||
StorageModule,
|
StorageModule,
|
||||||
TranslateModule.forChild(),
|
TranslateModule.forChild(),
|
||||||
ThingTranslateModule.forChild(),
|
ThingTranslateModule.forChild(),
|
||||||
UtilModule,
|
UtilModule,
|
||||||
|
GeoNavigationDirective,
|
||||||
|
ParseIsoPipeModule,
|
||||||
|
ParseDurationPipe,
|
||||||
|
DfnsFormatFrequencyPurePipe,
|
||||||
|
DfnsFormatRelativeDatePurePipe,
|
||||||
|
FormatPurePipeModule,
|
||||||
|
FormatDurationPurePipeModule,
|
||||||
|
FormatRelativeToNowPurePipeModule,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
CoordinatedSearchProvider,
|
CoordinatedSearchProvider,
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ describe('DataDetailComponent', () => {
|
|||||||
fixture = TestBed.createComponent(DataDetailComponent);
|
fixture = TestBed.createComponent(DataDetailComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
detailPage = fixture.debugElement;
|
detailPage = fixture.debugElement;
|
||||||
translateService.use('foo');
|
translateService.use('en');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -111,8 +111,8 @@ describe('DataDetailComponent', () => {
|
|||||||
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get a data item when the view is entered', () => {
|
it('should get a data item when initialized', () => {
|
||||||
comp.ionViewWillEnter();
|
comp.ngOnInit();
|
||||||
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, ContentChild, EventEmitter, Input, Output, TemplateRef} from '@angular/core';
|
import {Component, ContentChild, EventEmitter, Input, OnInit, Output, TemplateRef} from '@angular/core';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {ModalController, ViewWillEnter} from '@ionic/angular';
|
import {ModalController} from '@ionic/angular';
|
||||||
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||||
import {SCLanguageCode, SCSaveableThing, SCThings, SCUuid} from '@openstapps/core';
|
import {SCLanguageCode, SCSaveableThing, SCThings, SCUuid} from '@openstapps/core';
|
||||||
import {DataProvider, DataScope} from '../data.provider';
|
import {DataProvider, DataScope} from '../data.provider';
|
||||||
@@ -37,7 +37,7 @@ export interface ExternalDataLoadEvent {
|
|||||||
styleUrls: ['data-detail.scss'],
|
styleUrls: ['data-detail.scss'],
|
||||||
templateUrl: 'data-detail.html',
|
templateUrl: 'data-detail.html',
|
||||||
})
|
})
|
||||||
export class DataDetailComponent implements ViewWillEnter {
|
export class DataDetailComponent implements OnInit {
|
||||||
/**
|
/**
|
||||||
* The associated item
|
* The associated item
|
||||||
*
|
*
|
||||||
@@ -84,21 +84,15 @@ export class DataDetailComponent implements ViewWillEnter {
|
|||||||
return (thing as SCSaveableThing).data !== undefined;
|
return (thing as SCSaveableThing).data !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param route the route the page was accessed from
|
|
||||||
* @param dataProvider the data provider
|
|
||||||
* @param favoritesService the favorites provider
|
|
||||||
* @param modalController the modal controller
|
|
||||||
* @param translateService he translate provider
|
|
||||||
*/
|
|
||||||
constructor(
|
constructor(
|
||||||
protected readonly route: ActivatedRoute,
|
protected readonly route: ActivatedRoute,
|
||||||
|
router: Router,
|
||||||
private readonly dataProvider: DataProvider,
|
private readonly dataProvider: DataProvider,
|
||||||
private readonly favoritesService: FavoritesService,
|
private readonly favoritesService: FavoritesService,
|
||||||
readonly modalController: ModalController,
|
readonly modalController: ModalController,
|
||||||
translateService: TranslateService,
|
translateService: TranslateService,
|
||||||
) {
|
) {
|
||||||
|
this.inputItem = router.getCurrentNavigation()?.extras.state?.item;
|
||||||
this.language = translateService.currentLang as SCLanguageCode;
|
this.language = translateService.currentLang as SCLanguageCode;
|
||||||
translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||||
this.language = event.lang as SCLanguageCode;
|
this.language = event.lang as SCLanguageCode;
|
||||||
@@ -138,10 +132,7 @@ export class DataDetailComponent implements ViewWillEnter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
async ngOnInit() {
|
||||||
* Initialize
|
|
||||||
*/
|
|
||||||
async ionViewWillEnter() {
|
|
||||||
const uid = this.route.snapshot.paramMap.get('uid') || '';
|
const uid = this.route.snapshot.paramMap.get('uid') || '';
|
||||||
await this.getItem(uid ?? '', false);
|
await this.getItem(uid ?? '', false);
|
||||||
// fallback to the saved item (from favorites)
|
// fallback to the saved item (from favorites)
|
||||||
|
|||||||
@@ -37,32 +37,22 @@ export class DataPathComponent implements OnInit {
|
|||||||
@Input() maxItems = 2;
|
@Input() maxItems = 2;
|
||||||
|
|
||||||
@Input() set item(item: SCThings) {
|
@Input() set item(item: SCThings) {
|
||||||
// eslint-disable-next-line unicorn/prefer-ternary
|
|
||||||
if (item.type === SCThingType.Catalog && item.superCatalogs) {
|
if (item.type === SCThingType.Catalog && item.superCatalogs) {
|
||||||
this.path = new Promise(resolve =>
|
this.path = Promise.resolve([...item.superCatalogs!, item]);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
resolve([...item.superCatalogs!, item]),
|
|
||||||
);
|
|
||||||
} else if (item.type === SCThingType.Assessment && item.superAssessments) {
|
} else if (item.type === SCThingType.Assessment && item.superAssessments) {
|
||||||
this.path = new Promise(resolve =>
|
this.path = Promise.resolve([...item.superAssessments!, item]);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
resolve([...item.superAssessments!, item]),
|
|
||||||
);
|
|
||||||
} else if (
|
} else if (
|
||||||
item.type === SCThingType.AcademicEvent &&
|
item.type === SCThingType.AcademicEvent &&
|
||||||
item.catalogs &&
|
item.catalogs &&
|
||||||
(item.catalogs.length === 1 || this.routeStack.lastDataDetail)
|
(item.catalogs.length === 1 || this.routeStack.lastDataDetail)
|
||||||
) {
|
) {
|
||||||
const catalogWithoutReferences = item.catalogs[0];
|
|
||||||
const catalogPromise = (
|
|
||||||
item.catalogs.length === 1
|
|
||||||
? this.dataProvider.get(catalogWithoutReferences.uid, DataScope.Remote)
|
|
||||||
: this.routeStack.lastDataDetail
|
|
||||||
) as Promise<SCCatalog>;
|
|
||||||
|
|
||||||
this.path = new Promise(async resolve => {
|
this.path = new Promise(async resolve => {
|
||||||
const catalog = await catalogPromise;
|
const catalogWithoutReferences = item.catalogs![0];
|
||||||
const superCatalogs = catalog.superCatalogs;
|
const catalog =
|
||||||
|
item.catalogs!.length === 1
|
||||||
|
? await this.dataProvider.get(catalogWithoutReferences.uid, DataScope.Remote)
|
||||||
|
: this.routeStack.lastDataDetail;
|
||||||
|
const superCatalogs = (catalog as SCCatalog).superCatalogs;
|
||||||
|
|
||||||
resolve(
|
resolve(
|
||||||
superCatalogs
|
superCatalogs
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
*ngIf="offer.availabilityRange.gt ? offer.availabilityRange.gt : offer.availabilityRange.gte"
|
*ngIf="offer.availabilityRange.gt ? offer.availabilityRange.gt : offer.availabilityRange.gte"
|
||||||
>
|
>
|
||||||
{{ (offer.availabilityRange.gt ? offer.availabilityRange.gt : offer.availabilityRange.gte) |
|
{{ (offer.availabilityRange.gt ? offer.availabilityRange.gt : offer.availabilityRange.gte) |
|
||||||
amDateFormat : 'll' }}
|
dfnsParseIso | dfnsFormatPure : 'PPP' }}
|
||||||
</span>
|
</span>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
|
|||||||
@@ -20,16 +20,16 @@
|
|||||||
>
|
>
|
||||||
<ion-card-content>
|
<ion-card-content>
|
||||||
<p>
|
<p>
|
||||||
{{ 'data.types.origin.detail.CREATED' | translate | titlecase }}: {{ origin.created | amDateFormat :
|
{{ 'data.types.origin.detail.CREATED' | translate | titlecase }}: {{ origin.created | dfnsParseIso |
|
||||||
'll' }}
|
dfnsFormatPure : 'PPP' }}
|
||||||
</p>
|
</p>
|
||||||
<p *ngIf="origin.updated">
|
<p *ngIf="origin.updated">
|
||||||
{{ 'data.types.origin.detail.UPDATED' | translate | titlecase }}: {{ origin.updated | amDateFormat :
|
{{ 'data.types.origin.detail.UPDATED' | translate | titlecase }}: {{ origin.updated | dfnsParseIso |
|
||||||
'll' }}
|
dfnsFormatPure : 'PPP' }}
|
||||||
</p>
|
</p>
|
||||||
<p *ngIf="origin.modified">
|
<p *ngIf="origin.modified">
|
||||||
{{ 'data.types.origin.detail.MODIFIED' | translate | titlecase }}: {{ origin.modified | amDateFormat :
|
{{ 'data.types.origin.detail.MODIFIED' | translate | titlecase }}: {{ origin.modified | dfnsParseIso |
|
||||||
'll' }}
|
dfnsFormatPure : 'PPP' }}
|
||||||
</p>
|
</p>
|
||||||
<p *ngIf="origin.name">{{ 'data.types.origin.detail.MAINTAINER' | translate }}: {{ origin.name }}</p>
|
<p *ngIf="origin.name">{{ 'data.types.origin.detail.MAINTAINER' | translate }}: {{ origin.name }}</p>
|
||||||
<p *ngIf="origin.maintainer">
|
<p *ngIf="origin.maintainer">
|
||||||
@@ -46,12 +46,12 @@
|
|||||||
>
|
>
|
||||||
<ion-card-content>
|
<ion-card-content>
|
||||||
<p>
|
<p>
|
||||||
{{ 'data.types.origin.detail.INDEXED' | translate | titlecase }}: {{ origin.indexed | amDateFormat :
|
{{ 'data.types.origin.detail.INDEXED' | translate | titlecase }}: {{ origin.indexed | dfnsParseIso |
|
||||||
'll' }}
|
dfnsFormatPure : 'PPP'}}
|
||||||
</p>
|
</p>
|
||||||
<p *ngIf="origin.modified">
|
<p *ngIf="origin.modified">
|
||||||
{{ 'data.types.origin.detail.MODIFIED' | translate | titlecase }}: {{ origin.modified | amDateFormat :
|
{{ 'data.types.origin.detail.MODIFIED' | translate | titlecase }}: {{ origin.modified | dfnsParseIso |
|
||||||
'll' }}
|
dfnsFormatPure : 'PPP' }}
|
||||||
</p>
|
</p>
|
||||||
<p *ngIf="origin.name">{{ 'data.types.origin.detail.MAINTAINER' | translate }}: {{ origin.name }}</p>
|
<p *ngIf="origin.name">{{ 'data.types.origin.detail.MAINTAINER' | translate }}: {{ origin.name }}</p>
|
||||||
<p *ngIf="origin.maintainer">
|
<p *ngIf="origin.maintainer">
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable unicorn/no-useless-undefined */
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2023 StApps
|
* Copyright (C) 2023 StApps
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
@@ -12,60 +13,51 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, ElementRef, HostListener, Input} from '@angular/core';
|
import {ChangeDetectionStrategy, Component, ElementRef, HostListener, Input} from '@angular/core';
|
||||||
import {SCDish, SCRatingRequest, SCUuid} from '@openstapps/core';
|
import {SCDish, SCRatingRequest} from '@openstapps/core';
|
||||||
import {RatingProvider} from '../rating.provider';
|
import {RatingProvider} from '../rating.provider';
|
||||||
import {ratingAnimation} from './rating.animation';
|
import {ratingAnimation} from './rating.animation';
|
||||||
|
import {BehaviorSubject, filter, merge, mergeMap, of, ReplaySubject, withLatestFrom} from 'rxjs';
|
||||||
|
import {catchError, map} from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'stapps-rating',
|
selector: 'stapps-rating',
|
||||||
templateUrl: 'rating.html',
|
templateUrl: 'rating.html',
|
||||||
styleUrls: ['rating.scss'],
|
styleUrls: ['rating.scss'],
|
||||||
animations: [ratingAnimation],
|
animations: [ratingAnimation],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class StappsRatingComponent {
|
export class StappsRatingComponent {
|
||||||
rate = false;
|
performRating = new BehaviorSubject(false);
|
||||||
|
|
||||||
rated = false;
|
userRating = new BehaviorSubject<number | undefined>(undefined);
|
||||||
|
|
||||||
canBeRated = false;
|
dish = new ReplaySubject<SCDish>(1);
|
||||||
|
|
||||||
uid: SCUuid;
|
wasAlreadyRated = merge(
|
||||||
|
this.dish.pipe(mergeMap(({uid}) => this.ratingProvider.hasRated(uid))),
|
||||||
|
this.userRating.pipe(
|
||||||
|
filter(it => it !== undefined),
|
||||||
|
withLatestFrom(this.dish),
|
||||||
|
mergeMap(([rating, {uid}]) => this.ratingProvider.rate(uid, rating as SCRatingRequest['rating'])),
|
||||||
|
map(() => true),
|
||||||
|
catchError(() => of(false)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
rating?: number;
|
canBeRated = this.dish.pipe(mergeMap(dish => this.ratingProvider.canRate(dish)));
|
||||||
|
|
||||||
@Input() set item(value: SCDish) {
|
@Input({required: true}) set item(value: SCDish) {
|
||||||
this.uid = value.uid;
|
this.dish.next(value);
|
||||||
|
|
||||||
Promise.all([this.ratingProvider.canRate(value), this.ratingProvider.hasRated(this.uid)] as const).then(
|
|
||||||
([canRate, hasRated]) => {
|
|
||||||
this.canBeRated = canRate;
|
|
||||||
this.rated = hasRated;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(readonly elementRef: ElementRef, readonly ratingProvider: RatingProvider) {}
|
constructor(readonly elementRef: ElementRef, readonly ratingProvider: RatingProvider) {}
|
||||||
|
|
||||||
async submitRating(rating: number) {
|
|
||||||
this.rating = rating;
|
|
||||||
try {
|
|
||||||
await this.ratingProvider.rate(this.uid, rating as SCRatingRequest['rating']);
|
|
||||||
this.rated = true;
|
|
||||||
} catch {
|
|
||||||
this.rating = undefined;
|
|
||||||
// allow change detection to catch up first
|
|
||||||
setTimeout(() => {
|
|
||||||
this.rate = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostListener('document:mousedown', ['$event'])
|
@HostListener('document:mousedown', ['$event'])
|
||||||
clickOutside(event: MouseEvent) {
|
clickOutside(event: MouseEvent) {
|
||||||
if (this.rating) return;
|
if (this.userRating.value) return;
|
||||||
if (!this.elementRef.nativeElement.contains(event.target)) {
|
if (!this.elementRef.nativeElement.contains(event.target)) {
|
||||||
this.rate = false;
|
this.performRating.next(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,19 +14,23 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<ion-button
|
<ion-button
|
||||||
*ngIf="canBeRated"
|
*ngIf="canBeRated | async"
|
||||||
fill="clear"
|
fill="clear"
|
||||||
(click)="$event.stopPropagation(); rate = true"
|
(click)="$event.stopPropagation(); performRating.next(true)"
|
||||||
[disabled]="rated"
|
[disabled]="wasAlreadyRated | async"
|
||||||
>
|
>
|
||||||
<ion-icon slot="icon-only" color="medium" name="thumbs_up_down"></ion-icon>
|
<ion-icon slot="icon-only" color="medium" name="thumbs_up_down"></ion-icon>
|
||||||
</ion-button>
|
</ion-button>
|
||||||
|
|
||||||
<div class="rating-stars" *ngIf="rate && !rated" [@rating]="rating ? 'rated' : 'abandoned'">
|
<div
|
||||||
|
class="rating-stars"
|
||||||
|
*ngIf="(performRating | async) && (wasAlreadyRated | async) !== true"
|
||||||
|
[@rating]="(userRating | async) === undefined ? 'abandoned' : 'rated'"
|
||||||
|
>
|
||||||
<ion-icon
|
<ion-icon
|
||||||
[class.rated-value]="rating === i"
|
[class.rated-value]="(userRating | async) === i"
|
||||||
*ngFor="let i of [5, 4, 3, 2, 1]"
|
*ngFor="let i of [5, 4, 3, 2, 1]"
|
||||||
(click)="$event.stopPropagation(); submitRating(i)"
|
(click)="$event.stopPropagation(); userRating.next(i)"
|
||||||
slot="icon-only"
|
slot="icon-only"
|
||||||
size="32"
|
size="32"
|
||||||
color="medium"
|
color="medium"
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ export class DataListItemComponent {
|
|||||||
|
|
||||||
@Input() listItemEndInteraction = true;
|
@Input() listItemEndInteraction = true;
|
||||||
|
|
||||||
|
@Input() listItemChipInteraction = true;
|
||||||
|
|
||||||
@Input() lines = 'inset';
|
@Input() lines = 'inset';
|
||||||
|
|
||||||
@Input() forceHeight = false;
|
@Input() forceHeight = false;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<ng-template [dataListItemHost]="item"></ng-template>
|
<ng-template [dataListItemHost]="item"></ng-template>
|
||||||
<stapps-action-chip-list
|
<stapps-action-chip-list
|
||||||
*ngIf="appearance !== 'square'"
|
*ngIf="listItemChipInteraction && appearance !== 'square'"
|
||||||
slot="end"
|
slot="end"
|
||||||
[item]="item"
|
[item]="item"
|
||||||
></stapps-action-chip-list>
|
></stapps-action-chip-list>
|
||||||
|
|||||||
@@ -12,109 +12,96 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, OnInit} from '@angular/core';
|
import {ChangeDetectionStrategy, Component} from '@angular/core';
|
||||||
import {MapPosition} from '../../map/position.service';
|
import {MapPosition, PositionService} from '../../map/position.service';
|
||||||
import {SearchPageComponent} from './search-page.component';
|
|
||||||
import {Geolocation} from '@capacitor/geolocation';
|
import {Geolocation} from '@capacitor/geolocation';
|
||||||
import {BehaviorSubject} from 'rxjs';
|
import {BehaviorSubject, from} from 'rxjs';
|
||||||
import {pauseWhen} from '../../../util/pause-when';
|
import {pauseWhen} from '../../../util/rxjs/pause-when';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {map, retry, startWith, take} from 'rxjs/operators';
|
||||||
|
import {SCSearchFilter, SCSearchSort} from '@openstapps/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Presents a list of places for eating/drinking
|
* Presents a list of places for eating/drinking
|
||||||
*/
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'search-page.html',
|
selector: 'stapps-food-data-list',
|
||||||
styleUrls: ['../../data/list/search-page.scss'],
|
templateUrl: 'food-data-list.html',
|
||||||
|
styleUrls: ['food-data-list.scss'],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class FoodDataListComponent extends SearchPageComponent implements OnInit {
|
export class FoodDataListComponent {
|
||||||
title = 'canteens.title';
|
|
||||||
|
|
||||||
showNavigation = false;
|
|
||||||
|
|
||||||
isNotInView$ = new BehaviorSubject(true);
|
isNotInView$ = new BehaviorSubject(true);
|
||||||
|
|
||||||
/**
|
forcedFilter: SCSearchFilter = {
|
||||||
* Sets the forced filter to present only places for eating/drinking
|
arguments: {
|
||||||
*/
|
filters: [
|
||||||
ngOnInit() {
|
{
|
||||||
this.positionService
|
arguments: {
|
||||||
.watchCurrentLocation({enableHighAccuracy: false, maximumAge: 1000})
|
field: 'categories',
|
||||||
.pipe(pauseWhen(this.isNotInView$), takeUntilDestroyed(this.destroy$))
|
value: 'canteen',
|
||||||
.subscribe({
|
},
|
||||||
next: (position: MapPosition) => {
|
type: 'value',
|
||||||
this.positionService.position = position;
|
|
||||||
},
|
},
|
||||||
error: async _error => {
|
{
|
||||||
this.positionService.position = undefined;
|
arguments: {
|
||||||
await Geolocation.checkPermissions();
|
field: 'categories',
|
||||||
|
value: 'student canteen',
|
||||||
|
},
|
||||||
|
type: 'value',
|
||||||
},
|
},
|
||||||
});
|
{
|
||||||
this.showDefaultData = true;
|
arguments: {
|
||||||
|
field: 'categories',
|
||||||
|
value: 'cafe',
|
||||||
|
},
|
||||||
|
type: 'value',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arguments: {
|
||||||
|
field: 'categories',
|
||||||
|
value: 'restaurant',
|
||||||
|
},
|
||||||
|
type: 'value',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
operation: 'or',
|
||||||
|
},
|
||||||
|
type: 'boolean',
|
||||||
|
};
|
||||||
|
|
||||||
this.sortQuery = [
|
sortQuery = this.positionService
|
||||||
{
|
.watchCurrentLocation({
|
||||||
arguments: {field: 'name'},
|
enableHighAccuracy: false,
|
||||||
order: 'asc',
|
maximumAge: 1000,
|
||||||
type: 'ducet',
|
})
|
||||||
},
|
.pipe(
|
||||||
];
|
pauseWhen(this.isNotInView$),
|
||||||
|
retry({
|
||||||
this.forcedFilter = {
|
delay: () => from(Geolocation.checkPermissions()),
|
||||||
arguments: {
|
}),
|
||||||
filters: [
|
map<MapPosition, SCSearchSort[]>(({longitude, latitude}) => [
|
||||||
{
|
|
||||||
arguments: {
|
|
||||||
field: 'categories',
|
|
||||||
value: 'canteen',
|
|
||||||
},
|
|
||||||
type: 'value',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arguments: {
|
|
||||||
field: 'categories',
|
|
||||||
value: 'student canteen',
|
|
||||||
},
|
|
||||||
type: 'value',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arguments: {
|
|
||||||
field: 'categories',
|
|
||||||
value: 'cafe',
|
|
||||||
},
|
|
||||||
type: 'value',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arguments: {
|
|
||||||
field: 'categories',
|
|
||||||
value: 'restaurant',
|
|
||||||
},
|
|
||||||
type: 'value',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
operation: 'or',
|
|
||||||
},
|
|
||||||
type: 'boolean',
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.positionService.position) {
|
|
||||||
this.sortQuery = [
|
|
||||||
{
|
{
|
||||||
type: 'distance',
|
type: 'distance',
|
||||||
order: 'asc',
|
order: 'asc',
|
||||||
arguments: {
|
arguments: {
|
||||||
field: 'geo',
|
field: 'geo',
|
||||||
position: [this.positionService.position.longitude, this.positionService.position.latitude],
|
position: [longitude, latitude],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
]),
|
||||||
}
|
take(1),
|
||||||
|
startWith<SCSearchSort[]>([
|
||||||
|
{
|
||||||
|
arguments: {field: 'name'},
|
||||||
|
order: 'asc',
|
||||||
|
type: 'ducet',
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
super.ngOnInit();
|
constructor(private readonly positionService: PositionService) {}
|
||||||
}
|
|
||||||
|
|
||||||
async ionViewWillEnter() {
|
async ionViewWillEnter() {
|
||||||
await super.ionViewWillEnter();
|
|
||||||
this.isNotInView$.next(false);
|
this.isNotInView$.next(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<stapps-search-page
|
||||||
|
[forcedFilter]="forcedFilter"
|
||||||
|
[sortQuery]="sortQuery | async"
|
||||||
|
[title]="'canteens.title'"
|
||||||
|
[showNavigation]="false"
|
||||||
|
[showDefaultData]="true"
|
||||||
|
>
|
||||||
|
</stapps-search-page>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
:host {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
@@ -16,11 +16,13 @@
|
|||||||
import type {AnimationBuilder} from '@ionic/angular';
|
import type {AnimationBuilder} from '@ionic/angular';
|
||||||
import {AnimationController} from '@ionic/angular';
|
import {AnimationController} from '@ionic/angular';
|
||||||
import type {AnimationOptions} from '@ionic/angular/providers/nav-controller';
|
import type {AnimationOptions} from '@ionic/angular/providers/nav-controller';
|
||||||
|
import {inject} from '@angular/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function searchPageSwitchAnimation(animationController: AnimationController): AnimationBuilder {
|
export function searchPageSwitchAnimation(): AnimationBuilder {
|
||||||
|
const animationController = inject(AnimationController);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
return (_baseElement: HTMLElement, options: AnimationOptions | any) => {
|
return (_baseElement: HTMLElement, options: AnimationOptions | any) => {
|
||||||
const rootTransition = animationController
|
const rootTransition = animationController
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, DestroyRef, inject, Input, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {Keyboard} from '@capacitor/keyboard';
|
import {Keyboard} from '@capacitor/keyboard';
|
||||||
import {AlertController, AnimationBuilder, AnimationController} from '@ionic/angular';
|
import {AlertController} from '@ionic/angular';
|
||||||
import {Capacitor} from '@capacitor/core';
|
import {Capacitor} from '@capacitor/core';
|
||||||
import {
|
import {
|
||||||
SCFacet,
|
SCFacet,
|
||||||
@@ -32,7 +32,6 @@ import {ContextMenuService} from '../../menu/context/context-menu.service';
|
|||||||
import {SettingsProvider} from '../../settings/settings.provider';
|
import {SettingsProvider} from '../../settings/settings.provider';
|
||||||
import {DataRoutingService} from '../data-routing.service';
|
import {DataRoutingService} from '../data-routing.service';
|
||||||
import {DataProvider} from '../data.provider';
|
import {DataProvider} from '../data.provider';
|
||||||
import {PositionService} from '../../map/position.service';
|
|
||||||
import {ConfigProvider} from '../../config/config.provider';
|
import {ConfigProvider} from '../../config/config.provider';
|
||||||
import {searchPageSwitchAnimation} from './search-page-switch-animation';
|
import {searchPageSwitchAnimation} from './search-page-switch-animation';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
@@ -46,7 +45,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
|||||||
styleUrls: ['search-page.scss'],
|
styleUrls: ['search-page.scss'],
|
||||||
providers: [ContextMenuService],
|
providers: [ContextMenuService],
|
||||||
})
|
})
|
||||||
export class SearchPageComponent implements OnInit {
|
export class SearchPageComponent implements OnInit, OnChanges {
|
||||||
@Input() title = 'search.title';
|
@Input() title = 'search.title';
|
||||||
|
|
||||||
@Input() placeholder = 'search.search_bar.placeholder';
|
@Input() placeholder = 'search.search_bar.placeholder';
|
||||||
@@ -140,25 +139,12 @@ export class SearchPageComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* Api query sorting
|
* Api query sorting
|
||||||
*/
|
*/
|
||||||
sortQuery: SCSearchSort[] | undefined;
|
@Input() sortQuery: SCSearchSort[] | undefined;
|
||||||
|
|
||||||
destroy$ = inject(DestroyRef);
|
destroy$ = inject(DestroyRef);
|
||||||
|
|
||||||
routeAnimation: AnimationBuilder;
|
routeAnimation = searchPageSwitchAnimation();
|
||||||
|
|
||||||
/**
|
|
||||||
* Injects the providers and creates subscriptions
|
|
||||||
* @param alertController AlertController
|
|
||||||
* @param dataProvider DataProvider
|
|
||||||
* @param contextMenuService ContextMenuService
|
|
||||||
* @param settingsProvider SettingsProvider
|
|
||||||
* @param logger An angular logger
|
|
||||||
* @param dataRoutingService DataRoutingService
|
|
||||||
* @param router Router
|
|
||||||
* @param route ActivatedRoute
|
|
||||||
* @param positionService PositionService
|
|
||||||
* @param configProvider ConfigProvider
|
|
||||||
*/
|
|
||||||
constructor(
|
constructor(
|
||||||
protected readonly alertController: AlertController,
|
protected readonly alertController: AlertController,
|
||||||
protected dataProvider: DataProvider,
|
protected dataProvider: DataProvider,
|
||||||
@@ -168,18 +154,20 @@ export class SearchPageComponent implements OnInit {
|
|||||||
protected dataRoutingService: DataRoutingService,
|
protected dataRoutingService: DataRoutingService,
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
private readonly route: ActivatedRoute,
|
private readonly route: ActivatedRoute,
|
||||||
protected positionService: PositionService,
|
|
||||||
private readonly configProvider: ConfigProvider,
|
private readonly configProvider: ConfigProvider,
|
||||||
animationController: AnimationController,
|
) {}
|
||||||
) {
|
|
||||||
this.routeAnimation = searchPageSwitchAnimation(animationController);
|
async ngOnChanges(changes: SimpleChanges) {
|
||||||
|
if ('sortQuery' in changes) {
|
||||||
|
await this.fetchAndUpdateItems();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches items with set query configuration
|
* Fetches items with set query configuration
|
||||||
* @param append If true fetched data gets appended to existing, override otherwise (default false)
|
* @param append If true fetched data gets appended to existing, override otherwise (default false)
|
||||||
*/
|
*/
|
||||||
protected async fetchAndUpdateItems(append = false): Promise<void> {
|
async fetchAndUpdateItems(append = false): Promise<void> {
|
||||||
// build query search options
|
// build query search options
|
||||||
const searchOptions: SCSearchQuery = {
|
const searchOptions: SCSearchQuery = {
|
||||||
from: this.from,
|
from: this.from,
|
||||||
@@ -342,7 +330,7 @@ export class SearchPageComponent implements OnInit {
|
|||||||
.pipe(takeUntilDestroyed(this.destroy$))
|
.pipe(takeUntilDestroyed(this.destroy$))
|
||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
if (this.itemRouting) {
|
if (this.itemRouting) {
|
||||||
void this.router.navigate(['/data-detail', item.uid]);
|
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export class SimpleDataListComponent implements OnInit {
|
|||||||
.itemSelectListener()
|
.itemSelectListener()
|
||||||
.pipe(takeUntilDestroyed(this.destroy$))
|
.pipe(takeUntilDestroyed(this.destroy$))
|
||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
void this.router.navigate(['/data-detail', item.uid]);
|
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user