mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge branch 'master' into w2p-64503_Edit-collection-Content-Source-2
Conflicts: resources/i18n/en.json5 src/app/core/core.module.ts src/app/core/data/collection-data.service.spec.ts src/app/core/data/collection-data.service.ts src/app/core/data/request.models.ts src/app/shared/shared.module.ts
This commit is contained in:
37
.travis.yml
37
.travis.yml
@@ -1,10 +1,44 @@
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
env:
|
||||
# Install the latest docker-compose version for ci testing.
|
||||
# The default installation in travis is not compatible with the latest docker-compose file version.
|
||||
COMPOSE_VERSION: 1.24.1
|
||||
# The ci step will test the dspace-angular code against DSpace REST.
|
||||
# Direct that step to utilize a DSpace REST service that has been started in docker.
|
||||
DSPACE_REST_HOST: localhost
|
||||
DSPACE_REST_PORT: 8080
|
||||
DSPACE_REST_NAMESPACE: '/server/api'
|
||||
DSPACE_REST_SSL: false
|
||||
|
||||
before_install:
|
||||
# Docker Compose Install
|
||||
- curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
|
||||
- chmod +x docker-compose
|
||||
- sudo mv docker-compose /usr/local/bin
|
||||
|
||||
install:
|
||||
# Start up DSpace 7 using the entities database dump
|
||||
- docker-compose -f ./docker/docker-compose-travis.yml up -d
|
||||
# Use the dspace-cli image to populate the assetstore. Trigger a discovery and oai update
|
||||
- docker-compose -f ./docker/cli.yml -f ./docker/cli.assetstore.yml run --rm dspace-cli
|
||||
- travis_retry yarn install
|
||||
|
||||
before_script:
|
||||
# The following line could be enabled to verify that the rest server is responding.
|
||||
# Currently, "yarn run build" takes enough time to run to allow the service to be available
|
||||
#- curl http://localhost:8080/
|
||||
|
||||
after_script:
|
||||
- docker-compose -f ./docker/docker-compose-travis.yml down
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- google-chrome
|
||||
packages:
|
||||
- dpkg
|
||||
- google-chrome-stable
|
||||
|
||||
language: node_js
|
||||
@@ -18,9 +52,6 @@ cache:
|
||||
|
||||
bundler_args: --retry 5
|
||||
|
||||
install:
|
||||
- travis_retry yarn install
|
||||
|
||||
script:
|
||||
# Use Chromium instead of Chrome.
|
||||
- export CHROME_BIN=chromium-browser
|
||||
|
@@ -131,6 +131,11 @@ yarn run clean:prod
|
||||
yarn run clean:dist
|
||||
```
|
||||
|
||||
Running the application with Docker
|
||||
-----------------------------------
|
||||
See [Docker Runtime Options](docker/README.md)
|
||||
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
// This configuration is currently only being used for unit tests, end-to-end tests use environment.dev.ts
|
||||
module.exports = {
|
||||
|
||||
};
|
||||
|
79
docker/README.md
Normal file
79
docker/README.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# Docker Compose files
|
||||
|
||||
## docker directory
|
||||
- docker-compose.yml
|
||||
- Starts DSpace Angular with Docker Compose from the current branch. This file assumes that a DSpace 7 REST instance will also be started in Docker.
|
||||
- docker-compose-rest.yml
|
||||
- Runs a published instance of the DSpace 7 REST API - persists data in Docker volumes
|
||||
- docker-compose-travis.yml
|
||||
- Runs a published instance of the DSpace 7 REST API for CI testing. The database is re-populated from a SQL dump on each startup.
|
||||
- cli.yml
|
||||
- Docker compose file that provides a DSpace CLI container to work with a running DSpace REST container.
|
||||
- cli.assetstore.yml
|
||||
- Docker compose file that will download and install data into a DSpace REST assetstore. This script points to a default dataset that will be utilized for CI testing.
|
||||
- environment.dev.js
|
||||
- Environment file for running DSpace Angular in Docker
|
||||
- local.cfg
|
||||
- Environment file for running the DSpace 7 REST API in Docker.
|
||||
|
||||
|
||||
## To refresh / pull DSpace images from Dockerhub
|
||||
```
|
||||
docker-compose -f docker/docker-compose.yml pull
|
||||
```
|
||||
|
||||
## To build DSpace images using code in your branch
|
||||
```
|
||||
docker-compose -f docker/docker-compose.yml build
|
||||
```
|
||||
|
||||
## To start DSpace (REST and Angular) from your branch
|
||||
|
||||
```
|
||||
docker-compose -p d7 -f docker/docker-compose.yml -f docker/docker-compose-rest.yml up -d
|
||||
```
|
||||
|
||||
## Run DSpace REST and DSpace Angular from local branches.
|
||||
_The system will be started in 2 steps. Each step shares the same docker network._
|
||||
|
||||
From DSpace/DSpace (build as needed)
|
||||
```
|
||||
docker-compose -p d7 up -d
|
||||
```
|
||||
|
||||
From DSpace/DSpace-angular
|
||||
```
|
||||
docker-compose -p d7 -f docker/docker-compose.yml up -d
|
||||
```
|
||||
|
||||
## Ingest test data from AIPDIR
|
||||
|
||||
Create an administrator
|
||||
```
|
||||
docker-compose -p d7 -f docker/cli.yml run --rm dspace-cli create-administrator -e test@test.edu -f admin -l user -p admin -c en
|
||||
```
|
||||
|
||||
Load content from AIP files
|
||||
```
|
||||
docker-compose -p d7 -f docker/cli.yml -f ./docker/cli.ingest.yml run --rm dspace-cli
|
||||
```
|
||||
|
||||
## Alternative Ingest - Use Entities dataset
|
||||
_Delete your docker volumes or use a unique project (-p) name_
|
||||
|
||||
Start DSpace with Database Content from a database dump
|
||||
```
|
||||
docker-compose -p d7 -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f docker/db.entities.yml up -d
|
||||
```
|
||||
|
||||
Load assetstore content and trigger a re-index of the repository
|
||||
```
|
||||
docker-compose -p d7 -f docker/cli.yml -f docker/cli.assetstore.yml run --rm dspace-cli
|
||||
```
|
||||
|
||||
## End to end testing of the rest api (runs in travis).
|
||||
_In this instance, only the REST api runs in Docker using the Entities dataset. Travis will perform CI testing of Angular using Node to drive the tests._
|
||||
|
||||
```
|
||||
docker-compose -p d7ci -f docker/docker-compose-travis.yml up -d
|
||||
```
|
23
docker/cli.assetstore.yml
Normal file
23
docker/cli.assetstore.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
version: "3.7"
|
||||
|
||||
networks:
|
||||
dspacenet:
|
||||
|
||||
services:
|
||||
dspace-cli:
|
||||
networks:
|
||||
dspacenet: {}
|
||||
environment:
|
||||
- LOADASSETS=https://www.dropbox.com/s/zv7lj8j2lp3egjs/assetstore.tar.gz?dl=1
|
||||
entrypoint:
|
||||
- /bin/bash
|
||||
- '-c'
|
||||
- |
|
||||
if [ ! -z $${LOADASSETS} ]
|
||||
then
|
||||
curl $${LOADASSETS} -L -s --output /tmp/assetstore.tar.gz
|
||||
cd /dspace
|
||||
tar xvfz /tmp/assetstore.tar.gz
|
||||
fi
|
||||
|
||||
/dspace/bin/dspace index-discovery
|
32
docker/cli.ingest.yml
Normal file
32
docker/cli.ingest.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# The contents of this file are subject to the license and copyright
|
||||
# detailed in the LICENSE and NOTICE files at the root of the source
|
||||
# tree and available online at
|
||||
#
|
||||
# http://www.dspace.org/license/
|
||||
#
|
||||
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
dspace-cli:
|
||||
environment:
|
||||
- AIPZIP=https://github.com/DSpace-Labs/AIP-Files/raw/master/dogAndReport.zip
|
||||
- ADMIN_EMAIL=test@test.edu
|
||||
- AIPDIR=/tmp/aip-dir
|
||||
entrypoint:
|
||||
- /bin/bash
|
||||
- '-c'
|
||||
- |
|
||||
rm -rf $${AIPDIR}
|
||||
mkdir $${AIPDIR} /dspace/upload
|
||||
cd $${AIPDIR}
|
||||
pwd
|
||||
curl $${AIPZIP} -L -s --output aip.zip
|
||||
unzip aip.zip
|
||||
cd $${AIPDIR}
|
||||
|
||||
/dspace/bin/dspace packager -r -a -t AIP -e $${ADMIN_EMAIL} -f -u SITE*.zip
|
||||
/dspace/bin/dspace database update-sequences
|
||||
|
||||
/dspace/bin/dspace index-discovery
|
22
docker/cli.yml
Normal file
22
docker/cli.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
dspace-cli:
|
||||
image: "${DOCKER_OWNER:-dspace}/dspace-cli:${DSPACE_VER:-dspace-7_x}"
|
||||
container_name: dspace-cli
|
||||
#environment:
|
||||
volumes:
|
||||
- "assetstore:/dspace/assetstore"
|
||||
- "./local.cfg:/dspace/config/local.cfg"
|
||||
entrypoint: /dspace/bin/dspace
|
||||
command: help
|
||||
networks:
|
||||
- dspacenet
|
||||
tty: true
|
||||
stdin_open: true
|
||||
|
||||
volumes:
|
||||
assetstore:
|
||||
|
||||
networks:
|
||||
dspacenet:
|
16
docker/db.entities.yml
Normal file
16
docker/db.entities.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# The contents of this file are subject to the license and copyright
|
||||
# detailed in the LICENSE and NOTICE files at the root of the source
|
||||
# tree and available online at
|
||||
#
|
||||
# http://www.dspace.org/license/
|
||||
#
|
||||
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
dspacedb:
|
||||
image: dspace/dspace-postgres-pgcrypto:loadsql
|
||||
environment:
|
||||
# Double underbars in env names will be replaced with periods for apache commons
|
||||
- LOADSQL=https://www.dropbox.com/s/xh3ack0vg0922p2/configurable-entities-2019-05-08.sql?dl=1
|
59
docker/docker-compose-rest.yml
Normal file
59
docker/docker-compose-rest.yml
Normal file
@@ -0,0 +1,59 @@
|
||||
networks:
|
||||
dspacenet:
|
||||
services:
|
||||
dspace:
|
||||
container_name: dspace
|
||||
depends_on:
|
||||
- dspacedb
|
||||
image: dspace/dspace:dspace-7_x-jdk8-test
|
||||
networks:
|
||||
dspacenet:
|
||||
ports:
|
||||
- published: 8080
|
||||
target: 8080
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- assetstore:/dspace/assetstore
|
||||
- "./local.cfg:/dspace/config/local.cfg"
|
||||
# Ensure that the database is ready before starting tomcat
|
||||
entrypoint:
|
||||
- /bin/bash
|
||||
- '-c'
|
||||
- |
|
||||
/dspace/bin/dspace database migrate
|
||||
catalina.sh run
|
||||
dspacedb:
|
||||
container_name: dspacedb
|
||||
image: dspace/dspace-postgres-pgcrypto
|
||||
environment:
|
||||
PGDATA: /pgdata
|
||||
networks:
|
||||
dspacenet:
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- pgdata:/pgdata
|
||||
dspacesolr:
|
||||
container_name: dspacesolr
|
||||
image: dspace/dspace-solr
|
||||
networks:
|
||||
dspacenet:
|
||||
ports:
|
||||
- published: 8983
|
||||
target: 8983
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- solr_authority:/opt/solr/server/solr/authority/data
|
||||
- solr_oai:/opt/solr/server/solr/oai/data
|
||||
- solr_search:/opt/solr/server/solr/search/data
|
||||
- solr_statistics:/opt/solr/server/solr/statistics/data
|
||||
version: '3.7'
|
||||
volumes:
|
||||
assetstore:
|
||||
pgdata:
|
||||
solr_authority:
|
||||
solr_oai:
|
||||
solr_search:
|
||||
solr_statistics:
|
53
docker/docker-compose-travis.yml
Normal file
53
docker/docker-compose-travis.yml
Normal file
@@ -0,0 +1,53 @@
|
||||
networks:
|
||||
dspacenet:
|
||||
services:
|
||||
dspace:
|
||||
container_name: dspace
|
||||
depends_on:
|
||||
- dspacedb
|
||||
image: dspace/dspace:dspace-7_x-jdk8-test
|
||||
networks:
|
||||
dspacenet:
|
||||
ports:
|
||||
- published: 8080
|
||||
target: 8080
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- assetstore:/dspace/assetstore
|
||||
- "./local.cfg:/dspace/config/local.cfg"
|
||||
dspacedb:
|
||||
container_name: dspacedb
|
||||
environment:
|
||||
LOADSQL: https://www.dropbox.com/s/xh3ack0vg0922p2/configurable-entities-2019-05-08.sql?dl=1
|
||||
PGDATA: /pgdata
|
||||
image: dspace/dspace-postgres-pgcrypto:loadsql
|
||||
networks:
|
||||
dspacenet:
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- pgdata:/pgdata
|
||||
dspacesolr:
|
||||
container_name: dspacesolr
|
||||
image: dspace/dspace-solr
|
||||
networks:
|
||||
dspacenet:
|
||||
ports:
|
||||
- published: 8983
|
||||
target: 8983
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- solr_authority:/opt/solr/server/solr/authority/data
|
||||
- solr_oai:/opt/solr/server/solr/oai/data
|
||||
- solr_search:/opt/solr/server/solr/search/data
|
||||
- solr_statistics:/opt/solr/server/solr/statistics/data
|
||||
version: '3.7'
|
||||
volumes:
|
||||
assetstore:
|
||||
pgdata:
|
||||
solr_authority:
|
||||
solr_oai:
|
||||
solr_search:
|
||||
solr_statistics:
|
26
docker/docker-compose.yml
Normal file
26
docker/docker-compose.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
version: '3.7'
|
||||
networks:
|
||||
dspacenet:
|
||||
services:
|
||||
dspace-angular:
|
||||
container_name: dspace-angular
|
||||
environment:
|
||||
DSPACE_HOST: dspace-angular
|
||||
DSPACE_NAMESPACE: /
|
||||
DSPACE_PORT: '3000'
|
||||
DSPACE_SSL: "false"
|
||||
image: dspace/dspace-angular:latest
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile
|
||||
networks:
|
||||
dspacenet:
|
||||
ports:
|
||||
- published: 3000
|
||||
target: 3000
|
||||
- published: 9876
|
||||
target: 9876
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- ./environment.dev.js:/app/config/environment.dev.js
|
16
docker/environment.dev.js
Normal file
16
docker/environment.dev.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
module.exports = {
|
||||
rest: {
|
||||
ssl: false,
|
||||
host: 'localhost',
|
||||
port: 8080,
|
||||
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
|
||||
nameSpace: '/server/api'
|
||||
}
|
||||
};
|
6
docker/local.cfg
Normal file
6
docker/local.cfg
Normal file
@@ -0,0 +1,6 @@
|
||||
dspace.dir=/dspace
|
||||
db.url=jdbc:postgresql://dspacedb:5432/dspace
|
||||
dspace.hostname=dspace
|
||||
dspace.baseUrl=http://localhost:8080/server
|
||||
dspace.name=DSpace Started with Docker Compose
|
||||
solr.server=http://dspacesolr:8983/solr
|
14
package.json
14
package.json
@@ -10,6 +10,9 @@
|
||||
"engines": {
|
||||
"node": "8.* || >= 10.*"
|
||||
},
|
||||
"resolutions": {
|
||||
"set-value": ">= 2.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"global": "npm install -g @angular/cli marked node-gyp nodemon node-nightly npm-check-updates npm-run-all rimraf typescript ts-node typedoc webpack webpack-bundle-analyzer pm2 rollup",
|
||||
"clean:coverage": "rimraf coverage",
|
||||
@@ -22,10 +25,10 @@
|
||||
"clean:prod": "yarn run clean:coverage && yarn run clean:doc && yarn run clean:dist && yarn run clean:log && yarn run clean:json && yarn run clean:bld",
|
||||
"clean": "yarn run clean:prod && yarn run clean:node",
|
||||
"prebuild": "yarn run clean:bld && yarn run clean:dist",
|
||||
"prebuild:aot": "yarn run prebuild",
|
||||
"prebuild:ci": "yarn run prebuild",
|
||||
"prebuild:prod": "yarn run prebuild",
|
||||
"build": "node ./scripts/webpack.js --progress --mode development",
|
||||
"build:aot": "yarn run syncbuilddir && node ./scripts/webpack.js --env.aot --env.server --mode development && node ./scripts/webpack.js --env.aot --env.client --mode development",
|
||||
"build:ci": "yarn run syncbuilddir && node ./scripts/webpack.js --env.aot --env.server --mode development && node ./scripts/webpack.js --env.aot --env.client --mode development",
|
||||
"build:prod": "yarn run syncbuilddir && node ./scripts/webpack.js --env.aot --env.server --mode production && node ./scripts/webpack.js --env.aot --env.client --mode production",
|
||||
"postbuild:prod": "yarn run rollup",
|
||||
"rollup": "rollup -c rollup.config.js",
|
||||
@@ -51,10 +54,13 @@
|
||||
"debug:server": "node-nightly --inspect --debug-brk dist/server.js",
|
||||
"debug:build": "node-nightly --inspect --debug-brk node_modules/webpack/bin/webpack.js --mode development",
|
||||
"debug:build:prod": "node-nightly --inspect --debug-brk node_modules/webpack/bin/webpack.js --env.aot --env.client --env.server --mode production",
|
||||
"ci": "yarn run lint && yarn run build:aot && yarn run test:headless",
|
||||
"ci": "yarn run lint && yarn run build:ci && yarn run test:headless && npm-run-all -p -r server e2e",
|
||||
"protractor": "node node_modules/protractor/bin/protractor",
|
||||
"pree2e": "yarn run webdriver:update",
|
||||
"e2e": "yarn run protractor",
|
||||
"pretest": "yarn run clean:bld",
|
||||
"pretest:headless": "yarn run pretest",
|
||||
"pretest:watch": "yarn run pretest",
|
||||
"test": "karma start --single-run",
|
||||
"test:headless": "karma start --single-run --browsers ChromeHeadless",
|
||||
"test:watch": "karma start --no-single-run --auto-watch",
|
||||
@@ -109,6 +115,7 @@
|
||||
"https": "1.0.0",
|
||||
"js-cookie": "2.2.0",
|
||||
"js.clone": "0.0.3",
|
||||
"json5": "^2.1.0",
|
||||
"jsonschema": "1.2.2",
|
||||
"jwt-decode": "^2.2.0",
|
||||
"methods": "1.1.2",
|
||||
@@ -154,6 +161,7 @@
|
||||
"@types/hammerjs": "2.0.35",
|
||||
"@types/jasmine": "^2.8.6",
|
||||
"@types/js-cookie": "2.1.0",
|
||||
"@types/json5": "^0.0.30",
|
||||
"@types/lodash": "^4.14.110",
|
||||
"@types/memory-cache": "0.2.0",
|
||||
"@types/mime": "2.0.0",
|
||||
|
@@ -2,6 +2,7 @@
|
||||
"404.help": "Nepodařilo se najít stránku, kterou hledáte. Je možné, že stránka byla přesunuta nebo smazána. Pomocí tlačítka níže můžete přejít na domovskou stránku. ",
|
||||
"404.link.home-page": "Přejít na domovskou stránku",
|
||||
"404.page-not-found": "stránka nenalezena",
|
||||
|
||||
"admin.registries.bitstream-formats.description": "Tento seznam formátů souborů poskytuje informace o známých formátech a o úrovni jejich podpory.",
|
||||
"admin.registries.bitstream-formats.formats.no-items": "Žádné formáty souborů.",
|
||||
"admin.registries.bitstream-formats.formats.table.internal": "interní",
|
||||
@@ -13,29 +14,36 @@
|
||||
"admin.registries.bitstream-formats.formats.table.supportLevel.head": "Úroveň podpory",
|
||||
"admin.registries.bitstream-formats.head": "Registr formátů souborů",
|
||||
"admin.registries.bitstream-formats.title": "DSpace Angular :: Registr formátů souborů",
|
||||
"admin.registries.metadata.description": "Registr metadat je seznam všech metadatových polí dostupných v repozitáři. Tyto pole mohou být rozdělena do více schémat. DSpace však vyžaduje použití schématu kvalifikový Dublin Core.",
|
||||
|
||||
"admin.registries.metadata.description": "Registr metadat je seznam všech metadatových polí dostupných v repozitáři. Tyto pole mohou být rozdělena do více schémat. DSpace však vyžaduje použití schématu Kvalifikovaný Dublin Core.",
|
||||
"admin.registries.metadata.head": "Registr metadat",
|
||||
"admin.registries.metadata.schemas.no-items": "Žádná schémata metadat.",
|
||||
"admin.registries.metadata.schemas.table.id": "ID",
|
||||
"admin.registries.metadata.schemas.table.name": "Název",
|
||||
"admin.registries.metadata.schemas.table.namespace": "Jmenný prostor",
|
||||
"admin.registries.metadata.title": "DSpace Angular :: Registr metadat",
|
||||
|
||||
"admin.registries.schema.description": "Toto je schéma metadat pro „{{namespace}}“.",
|
||||
"admin.registries.schema.fields.head": "Pole schématu metadat",
|
||||
"admin.registries.schema.fields.no-items": "Žádná metadatová pole.",
|
||||
"admin.registries.schema.fields.table.field": "Pole",
|
||||
"admin.registries.schema.fields.table.scopenote": "Poznámka o rozsahu",
|
||||
"admin.registries.schema.head": "Metadata Schema",
|
||||
"admin.registries.schema.head": "Schéma metadat",
|
||||
"admin.registries.schema.title": "DSpace Angular :: Registr schémat metadat",
|
||||
|
||||
"auth.errors.invalid-user": "Neplatná e-mailová adresa nebo heslo.",
|
||||
"auth.messages.expired": "Vaše relace vypršela. Prosím, znova se přihlaste.",
|
||||
|
||||
"browse.title": "Prohlížíte {{ collection }} dle {{ field }} {{ value }}",
|
||||
|
||||
"collection.page.browse.recent.head": "Poslední příspěvky",
|
||||
"collection.page.license": "Licence",
|
||||
"collection.page.news": "Novinky",
|
||||
|
||||
"community.page.license": "Licence",
|
||||
"community.page.news": "Novinky",
|
||||
"community.sub-collection-list.head": "Kolekce v této komunitě",
|
||||
|
||||
"error.browse-by": "Chyba během stahování záznamů",
|
||||
"error.collection": "Chyba během stahování kolekce",
|
||||
"error.community": "Chyba během stahování komunity",
|
||||
@@ -48,9 +56,11 @@
|
||||
"error.top-level-communities": "Chyba během stahování komunit nejvyšší úrovně",
|
||||
"error.validation.license.notgranted": "Pro dokončení zaslání Musíte udělit licenci. Pokud v tuto chvíli tuto licenci nemůžete udělit, můžete svou práci uložit a později se k svému příspěveku vrátit nebo jej smazat.",
|
||||
"error.validation.pattern": "Tento vstup je omezen dle vzoru: {{ pattern }}.",
|
||||
|
||||
"footer.copyright": "copyright © 2002-{{ year }}",
|
||||
"footer.link.dspace": "software DSpace",
|
||||
"footer.link.duraspace": "DuraSpace",
|
||||
|
||||
"form.cancel": "Zrušit",
|
||||
"form.first-name": "Křestní jméno",
|
||||
"form.group-collapse": "Sbalit",
|
||||
@@ -64,11 +74,13 @@
|
||||
"form.remove": "Smazat",
|
||||
"form.search": "Hledat",
|
||||
"form.submit": "Odeslat",
|
||||
|
||||
"home.description": "",
|
||||
"home.title": "DSpace Angular :: Domů",
|
||||
"home.top-level-communities.head": "Komunity v DSpace",
|
||||
"home.top-level-communities.help": "Vybráním komunity můžete prohlížet její kolekce.",
|
||||
"item.page.abstract": "Abstract",
|
||||
|
||||
"item.page.abstract": "Abstrakt",
|
||||
"item.page.author": "Autor",
|
||||
"item.page.collections": "Kolekce",
|
||||
"item.page.date": "Datum",
|
||||
@@ -81,6 +93,7 @@
|
||||
"item.page.link.full": "Úplný záznam",
|
||||
"item.page.link.simple": "Minimální záznam",
|
||||
"item.page.uri": "URI",
|
||||
|
||||
"loading.browse-by": "Načítají se záznamy...",
|
||||
"loading.collection": "Načítá se kolekce...",
|
||||
"loading.community": "Načítá se komunita...",
|
||||
@@ -91,6 +104,7 @@
|
||||
"loading.search-results": "Načítají se výsledky hledání...",
|
||||
"loading.sub-collections": "Načítají se subkolekce...",
|
||||
"loading.top-level-communities": "Načítají se komunity nejvyšší úrovně...",
|
||||
|
||||
"login.form.email": "E-mailová adresa",
|
||||
"login.form.forgot-password": "Zapomněli jste své heslo?",
|
||||
"login.form.header": "Prosím, přihlaste se do DSpace",
|
||||
@@ -98,22 +112,29 @@
|
||||
"login.form.password": "Heslo",
|
||||
"login.form.submit": "Přihlásit se",
|
||||
"login.title": "Přihlásit se",
|
||||
|
||||
"logout.form.header": "Odhlásit se z DSpace",
|
||||
"logout.form.submit": "Odhlásit se",
|
||||
"logout.title": "Odhlásit se",
|
||||
|
||||
"nav.home": "Domů",
|
||||
"nav.login": "Přihlásit se",
|
||||
"nav.logout": "Odhlásit se",
|
||||
|
||||
"pagination.results-per-page": "Výsledků na stránku",
|
||||
"pagination.showing.detail": "{{ range }} z {{ total }}",
|
||||
"pagination.showing.label": "Zobrazují se záznamy ",
|
||||
"pagination.sort-direction": "Seřazení",
|
||||
|
||||
"search.description": "",
|
||||
"search.title": "DSpace Angular :: Hledat",
|
||||
|
||||
"search.filters.applied.f.author": "Autor",
|
||||
"search.filters.applied.f.dateIssued.max": "Do data",
|
||||
"search.filters.applied.f.dateIssued.min": "Od data",
|
||||
"search.filters.applied.f.has_content_in_original_bundle": "Má soubory",
|
||||
"search.filters.applied.f.subject": "Předmět",
|
||||
|
||||
"search.filters.filter.author.head": "Autor",
|
||||
"search.filters.filter.author.placeholder": "Jméno autora",
|
||||
"search.filters.filter.dateIssued.head": "Datum",
|
||||
@@ -126,12 +147,16 @@
|
||||
"search.filters.filter.show-more": "Zobrazit více",
|
||||
"search.filters.filter.subject.head": "Předmět",
|
||||
"search.filters.filter.subject.placeholder": "Předmět",
|
||||
|
||||
"search.filters.head": "Filtry",
|
||||
"search.filters.reset": "Obnovit filtry",
|
||||
|
||||
"search.form.search": "Hledat",
|
||||
"search.form.search_dspace": "Hledat v DSpace",
|
||||
|
||||
"search.results.head": "Výsledky hledání",
|
||||
"search.results.no-results": "Nebyli nalezeny žádné výsledky",
|
||||
|
||||
"search.sidebar.close": "Zpět na výsledky",
|
||||
"search.sidebar.filters.title": "Filtry",
|
||||
"search.sidebar.open": "Vyhledávací nástroje",
|
||||
@@ -139,11 +164,13 @@
|
||||
"search.sidebar.settings.rpp": "Výsledků na stránku",
|
||||
"search.sidebar.settings.sort-by": "Řadit dle",
|
||||
"search.sidebar.settings.title": "Nastavení",
|
||||
"search.title": "DSpace Angular :: Hledat",
|
||||
|
||||
"search.view-switch.show-grid": "Zobrazit mřížku",
|
||||
"search.view-switch.show-list": "Zobrazit seznam",
|
||||
|
||||
"sorting.dc.title.ASC": "Název vzestupně",
|
||||
"sorting.dc.title.DESC": "Název sestupně",
|
||||
"sorting.score.DESC": "Relevance",
|
||||
"title": "DSpace"
|
||||
|
||||
"title": "DSpace",
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
"404.help": "Die Seite, die Sie aufrufen wollten, konnte nicht gefunden werden. Sie könnte verschoben oder gelöscht worden sein. Mit dem Link unten kommen Sie zurück zur Startseite. ",
|
||||
"404.link.home-page": "Zurück zur Startseite",
|
||||
"404.page-not-found": "Seite nicht gefunden",
|
||||
|
||||
"admin.registries.bitstream-formats.description": "Diese Liste enhtält die in diesem Repositorium zulässigen Dateiformate und den jeweiligen Unterstützungsgrad.",
|
||||
"admin.registries.bitstream-formats.formats.no-items": "Es gibt keine Formate in dieser Referenzliste.",
|
||||
"admin.registries.bitstream-formats.formats.table.internal": "intern",
|
||||
@@ -13,6 +14,7 @@
|
||||
"admin.registries.bitstream-formats.formats.table.supportLevel.head": "Unterstützungsgrad",
|
||||
"admin.registries.bitstream-formats.head": "Referenzliste der Dateiformate",
|
||||
"admin.registries.bitstream-formats.title": "DSpace Angular :: Referenzliste der Dateiformate",
|
||||
|
||||
"admin.registries.metadata.description": "Die Metadatenreferenzliste beinhaltet alle Metadatenfelder, die zur Verfügung stehen. Die Felder können in unterschiedlichen Schemata enthalten sein. Nichtsdestotrotz benötigt DSpace mindestens qualifiziertes Dublin Core.",
|
||||
"admin.registries.metadata.head": "Metadatenreferenzliste",
|
||||
"admin.registries.metadata.schemas.no-items": "Es gbit keine Metadatenschemata.",
|
||||
@@ -20,6 +22,7 @@
|
||||
"admin.registries.metadata.schemas.table.name": "Name",
|
||||
"admin.registries.metadata.schemas.table.namespace": "Namensraum",
|
||||
"admin.registries.metadata.title": "DSpace Angular :: Metadatenreferenzliste",
|
||||
|
||||
"admin.registries.schema.description": "Dies ist das Metadatenschema für \"{{namespace}}\".",
|
||||
"admin.registries.schema.fields.head": "Felder in diesem Schema",
|
||||
"admin.registries.schema.fields.no-items": "Es gibt keine Felder in diesem Schema.",
|
||||
@@ -27,15 +30,19 @@
|
||||
"admin.registries.schema.fields.table.scopenote": "Gültigkeitsbereich",
|
||||
"admin.registries.schema.head": "Metadatenschemata",
|
||||
"admin.registries.schema.title": "DSpace Angular :: Referenzliste der Metadatenschemata",
|
||||
|
||||
"auth.errors.invalid-user": "Ungültige E-Mail-Adresse oder Passwort.",
|
||||
"auth.messages.expired": "Ihre Sitzung ist abgelaufen, bitte melden Sie sich erneut an.",
|
||||
|
||||
"browse.title": "Anzeige {{ collection }} nach {{ field }} {{ value }}",
|
||||
"collection.page.browse.recent.head": "Aktuellste Veröffentlichungen",
|
||||
"collection.page.license": "Lizenz",
|
||||
"collection.page.news": "Neuigkeiten",
|
||||
|
||||
"community.page.license": "Lizenz",
|
||||
"community.page.news": "Neuigkeiten",
|
||||
"community.sub-collection-list.head": "Sammlungen in diesem Bereich",
|
||||
|
||||
"error.browse-by": "Fehler beim Laden der Ressourcen",
|
||||
"error.collection": "Fehler beim Laden der Sammlung.",
|
||||
"error.community": "Fehler beim Laden des Bereiches.",
|
||||
@@ -48,9 +55,11 @@
|
||||
"error.top-level-communities": "Fehler beim Laden der Hauptbereiche.",
|
||||
"error.validation.license.notgranted": "Sie müssen der Lizenz zustimmen, um die Ressource einzureichen. Wenn dies zur Zeit nicht geht, können Sie die Einreichung speichern und später wiederaufnehmen oder löschen.",
|
||||
"error.validation.pattern": "Die Eingabe kann nur folgendes Muster haben: {{ pattern }}.",
|
||||
|
||||
"footer.copyright": "Copyright © 2002-{{ year }}",
|
||||
"footer.link.dspace": "DSpace Software",
|
||||
"footer.link.duraspace": "DuraSpace",
|
||||
|
||||
"form.cancel": "Abbrechen",
|
||||
"form.first-name": "Vorname",
|
||||
"form.group-collapse": "Weniger",
|
||||
@@ -64,10 +73,12 @@
|
||||
"form.remove": "Löschen",
|
||||
"form.search": "Suchen",
|
||||
"form.submit": "Los",
|
||||
|
||||
"home.description": "",
|
||||
"home.title": "DSpace Angular :: Startseite",
|
||||
"home.top-level-communities.head": "Bereiche in DSpace",
|
||||
"home.top-level-communities.help": "Wählen Sie einen Bereich, um seine Sammlungen einzusehen.",
|
||||
|
||||
"item.page.abstract": "Kurzfassung",
|
||||
"item.page.author": "Autor",
|
||||
"item.page.collections": "Sammlungen",
|
||||
@@ -81,6 +92,7 @@
|
||||
"item.page.link.full": "Vollanzeige",
|
||||
"item.page.link.simple": "Kurzanzeige",
|
||||
"item.page.uri": "URI",
|
||||
|
||||
"loading.browse-by": "Die Ressourcen werden geladen ...",
|
||||
"loading.collection": "Die Sammlung wird geladen ...",
|
||||
"loading.community": "Der Bereich wird geladen ...",
|
||||
@@ -91,6 +103,7 @@
|
||||
"loading.search-results": "Die Suchergebnisse werden geladen ...",
|
||||
"loading.sub-collections": "Die untergeordneten Sammlungen werden geladen ...",
|
||||
"loading.top-level-communities": "Die Hauptbereiche werden geladen ...",
|
||||
|
||||
"login.form.email": "E-Mail-Adresse",
|
||||
"login.form.forgot-password": "Haben Sie Ihr Passwort vergessen?",
|
||||
"login.form.header": "Bitte Loggen Sie sich ein.",
|
||||
@@ -98,22 +111,29 @@
|
||||
"login.form.password": "Passwort",
|
||||
"login.form.submit": "Einloggen",
|
||||
"login.title": "Einloggen",
|
||||
|
||||
"logout.form.header": "Ausloggen aus DSpace",
|
||||
"logout.form.submit": "Ausloggen",
|
||||
"logout.title": "Ausloggen",
|
||||
|
||||
"nav.home": "Zur Startseite",
|
||||
"nav.login": "Anmelden",
|
||||
"nav.logout": "Abmelden",
|
||||
|
||||
"pagination.results-per-page": "Ergebnisse pro Seite",
|
||||
"pagination.showing.detail": "{{ range }} bis {{ total }}",
|
||||
"pagination.showing.label": "Anzeige der Treffer ",
|
||||
"pagination.sort-direction": "Sortiermöglichkeiten",
|
||||
|
||||
"search.description": "",
|
||||
"search.title": "DSpace Angular :: Suche",
|
||||
|
||||
"search.filters.applied.f.author": "Autor",
|
||||
"search.filters.applied.f.dateIssued.max": "Enddatum",
|
||||
"search.filters.applied.f.dateIssued.min": "Anfangsdatum",
|
||||
"search.filters.applied.f.has_content_in_original_bundle": "Besitzt Dateien",
|
||||
"search.filters.applied.f.subject": "Thema",
|
||||
|
||||
"search.filters.filter.author.head": "Autor",
|
||||
"search.filters.filter.author.placeholder": "Autor",
|
||||
"search.filters.filter.dateIssued.head": "Datum",
|
||||
@@ -126,12 +146,16 @@
|
||||
"search.filters.filter.show-more": "Zeige mehr",
|
||||
"search.filters.filter.subject.head": "Schlagwort",
|
||||
"search.filters.filter.subject.placeholder": "Schlagwort",
|
||||
|
||||
"search.filters.head": "Filter",
|
||||
"search.filters.reset": "Filter zurücksetzen",
|
||||
|
||||
"search.form.search": "Suche",
|
||||
"search.form.search_dspace": "DSpace durchsuchen",
|
||||
|
||||
"search.results.head": "Suchergebnisse",
|
||||
"search.results.no-results": "Zu dieser Suche gibt es keine Treffer.",
|
||||
|
||||
"search.sidebar.close": "Zurück zu den Ergebnissen",
|
||||
"search.sidebar.filters.title": "Filter",
|
||||
"search.sidebar.open": "Suchwerkzeuge",
|
||||
@@ -139,11 +163,13 @@
|
||||
"search.sidebar.settings.rpp": "Treffer pro Seite",
|
||||
"search.sidebar.settings.sort-by": "Sortiere nach",
|
||||
"search.sidebar.settings.title": "Einstellungen",
|
||||
"search.title": "DSpace Angular :: Suche",
|
||||
|
||||
"search.view-switch.show-grid": "Zeige als Raster",
|
||||
"search.view-switch.show-list": "Zeige als Liste",
|
||||
|
||||
"sorting.dc.title.ASC": "Titel aufsteigend",
|
||||
"sorting.dc.title.DESC": "Titel absteigend",
|
||||
"sorting.score.DESC": "Relevanz",
|
||||
"title": "DSpace"
|
||||
|
||||
"title": "DSpace",
|
||||
}
|
@@ -2,17 +2,50 @@
|
||||
"404.help": "We can't find the page you're looking for. The page may have been moved or deleted. You can use the button below to get back to the home page. ",
|
||||
"404.link.home-page": "Take me to the home page",
|
||||
"404.page-not-found": "page not found",
|
||||
|
||||
"admin.registries.bitstream-formats.create.failure.content": "An error occurred while creating the new bitstream format.",
|
||||
"admin.registries.bitstream-formats.create.failure.head": "Failure",
|
||||
"admin.registries.bitstream-formats.create.head": "Create Bitstream format",
|
||||
"admin.registries.bitstream-formats.create.new": "Add a new bitstream format",
|
||||
"admin.registries.bitstream-formats.create.success.content": "The new bitstream format was successfully created.",
|
||||
"admin.registries.bitstream-formats.create.success.head": "Success",
|
||||
"admin.registries.bitstream-formats.delete.failure.amount": "Failed to remove {{ amount }} format(s)",
|
||||
"admin.registries.bitstream-formats.delete.failure.head": "Failure",
|
||||
"admin.registries.bitstream-formats.delete.success.amount": "Successfully removed {{ amount }} format(s)",
|
||||
"admin.registries.bitstream-formats.delete.success.head": "Success",
|
||||
"admin.registries.bitstream-formats.description": "This list of bitstream formats provides information about known formats and their support level.",
|
||||
"admin.registries.bitstream-formats.formats.no-items": "No bitstream formats to show.",
|
||||
"admin.registries.bitstream-formats.formats.table.internal": "internal",
|
||||
"admin.registries.bitstream-formats.formats.table.mimetype": "MIME Type",
|
||||
"admin.registries.bitstream-formats.formats.table.name": "Name",
|
||||
"admin.registries.bitstream-formats.formats.table.supportLevel.0": "Unknown",
|
||||
"admin.registries.bitstream-formats.formats.table.supportLevel.1": "Known",
|
||||
"admin.registries.bitstream-formats.formats.table.supportLevel.2": "Support",
|
||||
"admin.registries.bitstream-formats.formats.table.supportLevel.head": "Support Level",
|
||||
"admin.registries.bitstream-formats.edit.description.hint": "",
|
||||
"admin.registries.bitstream-formats.edit.description.label": "Description",
|
||||
"admin.registries.bitstream-formats.edit.extensions.hint": "Extensions are file extensions that are used to automatically identify the format of uploaded files. You can enter several extensions for each format.",
|
||||
"admin.registries.bitstream-formats.edit.extensions.label": "File extensions",
|
||||
"admin.registries.bitstream-formats.edit.extensions.placeholder": "Enter a file extenstion without the dot",
|
||||
"admin.registries.bitstream-formats.edit.failure.content": "An error occurred while editing the bitstream format.",
|
||||
"admin.registries.bitstream-formats.edit.failure.head": "Failure",
|
||||
"admin.registries.bitstream-formats.edit.head": "Bitstream format: {{ format }}",
|
||||
"admin.registries.bitstream-formats.edit.internal.hint": "Formats marked as internal are are hidden from the user, and used for administrative purposes.",
|
||||
"admin.registries.bitstream-formats.edit.internal.label": "Internal",
|
||||
"admin.registries.bitstream-formats.edit.mimetype.hint": "The MIME type associated with this format, does not have to be unique.",
|
||||
"admin.registries.bitstream-formats.edit.mimetype.label": "MIME Type",
|
||||
"admin.registries.bitstream-formats.edit.shortDescription.hint": "A unique name for this format, (e.g. Microsoft Word XP or Microsoft Word 2000)",
|
||||
"admin.registries.bitstream-formats.edit.shortDescription.label": "Name",
|
||||
"admin.registries.bitstream-formats.edit.success.content": "The bitstream format was successfully edited.",
|
||||
"admin.registries.bitstream-formats.edit.success.head": "Success",
|
||||
"admin.registries.bitstream-formats.edit.supportLevel.hint": "The level of support your institution pledges for this format.",
|
||||
"admin.registries.bitstream-formats.edit.supportLevel.label": "Support level",
|
||||
"admin.registries.bitstream-formats.head": "Bitstream Format Registry",
|
||||
"admin.registries.bitstream-formats.no-items": "No bitstream formats to show.",
|
||||
"admin.registries.bitstream-formats.table.delete": "Delete selected",
|
||||
"admin.registries.bitstream-formats.table.deselect-all": "Deselect all",
|
||||
"admin.registries.bitstream-formats.table.internal": "internal",
|
||||
"admin.registries.bitstream-formats.table.mimetype": "MIME Type",
|
||||
"admin.registries.bitstream-formats.table.name": "Name",
|
||||
"admin.registries.bitstream-formats.table.return": "Return",
|
||||
"admin.registries.bitstream-formats.table.supportLevel.KNOWN": "Known",
|
||||
"admin.registries.bitstream-formats.table.supportLevel.SUPPORTED": "Supported",
|
||||
"admin.registries.bitstream-formats.table.supportLevel.UNKNOWN": "Unknown",
|
||||
"admin.registries.bitstream-formats.table.supportLevel.head": "Support Level",
|
||||
"admin.registries.bitstream-formats.title": "DSpace Angular :: Bitstream Format Registry",
|
||||
|
||||
"admin.registries.metadata.description": "The metadata registry maintains a list of all metadata fields available in the repository. These fields may be divided amongst multiple schemas. However, DSpace requires the qualified Dublin Core schema.",
|
||||
"admin.registries.metadata.form.create": "Create metadata schema",
|
||||
"admin.registries.metadata.form.edit": "Edit metadata schema",
|
||||
@@ -25,6 +58,7 @@
|
||||
"admin.registries.metadata.schemas.table.name": "Name",
|
||||
"admin.registries.metadata.schemas.table.namespace": "Namespace",
|
||||
"admin.registries.metadata.title": "DSpace Angular :: Metadata Registry",
|
||||
|
||||
"admin.registries.schema.description": "This is the metadata schema for \"{{namespace}}\".",
|
||||
"admin.registries.schema.fields.head": "Schema metadata fields",
|
||||
"admin.registries.schema.fields.no-items": "No metadata fields to show.",
|
||||
@@ -49,8 +83,10 @@
|
||||
"admin.registries.schema.notification.success": "Success",
|
||||
"admin.registries.schema.return": "Return",
|
||||
"admin.registries.schema.title": "DSpace Angular :: Metadata Schema Registry",
|
||||
|
||||
"auth.errors.invalid-user": "Invalid email address or password.",
|
||||
"auth.messages.expired": "Your session has expired. Please log in again.",
|
||||
|
||||
"browse.comcol.by.author": "By Author",
|
||||
"browse.comcol.by.dateissued": "By Issue Date",
|
||||
"browse.comcol.by.subject": "By Subject",
|
||||
@@ -81,7 +117,9 @@
|
||||
"browse.startsWith.type_date": "Or type in a date (year-month):",
|
||||
"browse.startsWith.type_text": "Or enter first few letters:",
|
||||
"browse.title": "Browsing {{ collection }} by {{ field }} {{ value }}",
|
||||
|
||||
"chips.remove": "Remove chip",
|
||||
|
||||
"collection.create.head": "Create a Collection",
|
||||
"collection.create.sub-head": "Create a Collection for Community {{ parent }}",
|
||||
"collection.delete.cancel": "Cancel",
|
||||
@@ -90,9 +128,30 @@
|
||||
"collection.delete.notification.fail": "Collection could not be deleted",
|
||||
"collection.delete.notification.success": "Successfully deleted collection",
|
||||
"collection.delete.text": "Are you sure you want to delete collection \"{{ dso }}\"",
|
||||
|
||||
"collection.edit.delete": "Delete this collection",
|
||||
"collection.edit.head": "Edit Collection",
|
||||
|
||||
"collection.edit.item-mapper.cancel": "Cancel",
|
||||
"collection.edit.item-mapper.collection": "Collection: \"<b>{{name}}</b>\"",
|
||||
"collection.edit.item-mapper.confirm": "Map selected items",
|
||||
"collection.edit.item-mapper.description": "This is the item mapper tool that allows collection administrators to map items from other collections into this collection. You can search for items from other collections and map them, or browse the list of currently mapped items.",
|
||||
"collection.edit.item-mapper.head": "Item Mapper - Map Items from Other Collections",
|
||||
"collection.edit.item-mapper.no-search": "Please enter a query to search",
|
||||
"collection.edit.item-mapper.notifications.map.error.content": "Errors occurred for mapping of {{amount}} items.",
|
||||
"collection.edit.item-mapper.notifications.map.error.head": "Mapping errors",
|
||||
"collection.edit.item-mapper.notifications.map.success.content": "Successfully mapped {{amount}} items.",
|
||||
"collection.edit.item-mapper.notifications.map.success.head": "Mapping completed",
|
||||
"collection.edit.item-mapper.notifications.unmap.error.content": "Errors occurred for removing the mappings of {{amount}} items.",
|
||||
"collection.edit.item-mapper.notifications.unmap.error.head": "Remove mapping errors",
|
||||
"collection.edit.item-mapper.notifications.unmap.success.content": "Successfully removed the mappings of {{amount}} items.",
|
||||
"collection.edit.item-mapper.notifications.unmap.success.head": "Remove mapping completed",
|
||||
"collection.edit.item-mapper.remove": "Remove selected item mappings",
|
||||
"collection.edit.item-mapper.tabs.browse": "Browse mapped items",
|
||||
"collection.edit.item-mapper.tabs.map": "Map new items",
|
||||
|
||||
"collection.edit.return": "Return",
|
||||
|
||||
"collection.edit.tabs.curate.head": "Curate",
|
||||
"collection.edit.tabs.curate.title": "Collection Edit - Curate",
|
||||
"collection.edit.tabs.metadata.head": "Edit Metadata",
|
||||
@@ -125,11 +184,20 @@
|
||||
"collection.form.rights": "Copyright text (HTML)",
|
||||
"collection.form.tableofcontents": "News (HTML)",
|
||||
"collection.form.title": "Name",
|
||||
|
||||
"collection.page.browse.recent.head": "Recent Submissions",
|
||||
"collection.page.browse.recent.empty": "No items to show",
|
||||
"collection.page.handle": "Permanent URI for this collection",
|
||||
"collection.page.license": "License",
|
||||
"collection.page.news": "News",
|
||||
|
||||
"collection.select.confirm": "Confirm selected",
|
||||
"collection.select.empty": "No collections to show",
|
||||
"collection.select.table.title": "Title",
|
||||
|
||||
"collection.source.update.notifications.error.content": "The provided settings have been tested and didn't work.",
|
||||
"collection.source.update.notifications.error.title": "Server Error",
|
||||
|
||||
"community.create.head": "Create a Community",
|
||||
"community.create.sub-head": "Create a Sub-Community for Community {{ parent }}",
|
||||
"community.delete.cancel": "Cancel",
|
||||
@@ -153,10 +221,13 @@
|
||||
"community.form.rights": "Copyright text (HTML)",
|
||||
"community.form.tableofcontents": "News (HTML)",
|
||||
"community.form.title": "Name",
|
||||
"community.page.handle": "Permanent URI for this community",
|
||||
"community.page.license": "License",
|
||||
"community.page.news": "News",
|
||||
"community.all-lists.head": "Subcommunities and Collections",
|
||||
"community.sub-collection-list.head": "Collections of this Community",
|
||||
"community.sub-community-list.head": "Communities of this Community",
|
||||
|
||||
"dso-selector.create.collection.head": "New collection",
|
||||
"dso-selector.create.community.head": "New community",
|
||||
"dso-selector.create.community.sub-level": "Create a new community in",
|
||||
@@ -167,11 +238,14 @@
|
||||
"dso-selector.edit.item.head": "Edit item",
|
||||
"dso-selector.no-results": "No {{ type }} found",
|
||||
"dso-selector.placeholder": "Search for a {{ type }}",
|
||||
|
||||
"error.browse-by": "Error fetching items",
|
||||
"error.collection": "Error fetching collection",
|
||||
"error.collections": "Error fetching collections",
|
||||
"error.community": "Error fetching community",
|
||||
"error.default": "Error",
|
||||
"error.item": "Error fetching item",
|
||||
"error.items": "Error fetching items",
|
||||
"error.objects": "Error fetching objects",
|
||||
"error.recent-submissions": "Error fetching recent submissions",
|
||||
"error.search-results": "Error fetching search results",
|
||||
@@ -181,9 +255,11 @@
|
||||
"error.top-level-communities": "Error fetching top-level communities",
|
||||
"error.validation.license.notgranted": "You must grant this license to complete your submission. If you are unable to grant this license at this time you may save your work and return later or remove the submission.",
|
||||
"error.validation.pattern": "This input is restricted by the current pattern: {{ pattern }}.",
|
||||
|
||||
"footer.copyright": "copyright © 2002-{{ year }}",
|
||||
"footer.link.dspace": "DSpace software",
|
||||
"footer.link.duraspace": "DuraSpace",
|
||||
|
||||
"form.cancel": "Cancel",
|
||||
"form.clear": "Clear",
|
||||
"form.clear-help": "Click here to remove the selected value",
|
||||
@@ -205,10 +281,12 @@
|
||||
"form.search": "Search",
|
||||
"form.search-help": "Click here to looking for an existing correspondence",
|
||||
"form.submit": "Submit",
|
||||
|
||||
"home.description": "",
|
||||
"home.title": "DSpace Angular :: Home",
|
||||
"home.top-level-communities.head": "Communities in DSpace",
|
||||
"home.top-level-communities.help": "Select a community to browse its collections.",
|
||||
|
||||
"item.edit.delete.cancel": "Cancel",
|
||||
"item.edit.delete.confirm": "Delete",
|
||||
"item.edit.delete.description": "Are you sure this item should be completely deleted? Caution: At present, no tombstone would be left.",
|
||||
@@ -216,6 +294,25 @@
|
||||
"item.edit.delete.header": "Delete item: {{ id }}",
|
||||
"item.edit.delete.success": "The item has been deleted",
|
||||
"item.edit.head": "Edit Item",
|
||||
|
||||
"item.edit.item-mapper.buttons.add": "Map item to selected collections",
|
||||
"item.edit.item-mapper.buttons.remove": "Remove item's mapping for selected collections",
|
||||
"item.edit.item-mapper.cancel": "Cancel",
|
||||
"item.edit.item-mapper.description": "This is the item mapper tool that allows administrators to map this item to other collections. You can search for collections and map them, or browse the list of collections the item is currently mapped to.",
|
||||
"item.edit.item-mapper.head": "Item Mapper - Map Item to Collections",
|
||||
"item.edit.item-mapper.item": "Item: \"<b>{{name}}</b>\"",
|
||||
"item.edit.item-mapper.no-search": "Please enter a query to search",
|
||||
"item.edit.item-mapper.notifications.add.error.content": "Errors occurred for mapping of item to {{amount}} collections.",
|
||||
"item.edit.item-mapper.notifications.add.error.head": "Mapping errors",
|
||||
"item.edit.item-mapper.notifications.add.success.content": "Successfully mapped item to {{amount}} collections.",
|
||||
"item.edit.item-mapper.notifications.add.success.head": "Mapping completed",
|
||||
"item.edit.item-mapper.notifications.remove.error.content": "Errors occurred for the removal of the mapping to {{amount}} collections.",
|
||||
"item.edit.item-mapper.notifications.remove.error.head": "Removal of mapping errors",
|
||||
"item.edit.item-mapper.notifications.remove.success.content": "Successfully removed mapping of item to {{amount}} collections.",
|
||||
"item.edit.item-mapper.notifications.remove.success.head": "Removal of mapping completed",
|
||||
"item.edit.item-mapper.tabs.browse": "Browse mapped collections",
|
||||
"item.edit.item-mapper.tabs.map": "Map new collections",
|
||||
|
||||
"item.edit.metadata.add-button": "Add",
|
||||
"item.edit.metadata.discard-button": "Discard",
|
||||
"item.edit.metadata.edit.buttons.edit": "Edit",
|
||||
@@ -237,33 +334,65 @@
|
||||
"item.edit.metadata.notifications.saved.title": "Metadata saved",
|
||||
"item.edit.metadata.reinstate-button": "Undo",
|
||||
"item.edit.metadata.save-button": "Save",
|
||||
|
||||
"item.edit.modify.overview.field": "Field",
|
||||
"item.edit.modify.overview.language": "Language",
|
||||
"item.edit.modify.overview.value": "Value",
|
||||
|
||||
"item.edit.move.cancel": "Cancel",
|
||||
"item.edit.move.description": "Select the collection you wish to move this item to. To narrow down the list of displayed collections, you can enter a search query in the box.",
|
||||
"item.edit.move.error": "An error occured when attempting to move the item",
|
||||
"item.edit.move.head": "Move item: {{id}}",
|
||||
"item.edit.move.inheritpolicies.checkbox": "Inherit policies",
|
||||
"item.edit.move.inheritpolicies.description": "Inherit the default policies of the destination collection",
|
||||
"item.edit.move.move": "Move",
|
||||
"item.edit.move.processing": "Moving...",
|
||||
"item.edit.move.search.placeholder": "Enter a search query to look for collections",
|
||||
"item.edit.move.success": "The item has been moved succesfully",
|
||||
"item.edit.move.title": "Move item",
|
||||
|
||||
"item.edit.private.cancel": "Cancel",
|
||||
"item.edit.private.confirm": "Make it Private",
|
||||
"item.edit.private.description": "Are you sure this item should be made private in the archive?",
|
||||
"item.edit.private.error": "An error occurred while making the item private",
|
||||
"item.edit.private.header": "Make item private: {{ id }}",
|
||||
"item.edit.private.success": "The item is now private",
|
||||
|
||||
"item.edit.public.cancel": "Cancel",
|
||||
"item.edit.public.confirm": "Make it Public",
|
||||
"item.edit.public.description": "Are you sure this item should be made public in the archive?",
|
||||
"item.edit.public.error": "An error occurred while making the item public",
|
||||
"item.edit.public.header": "Make item public: {{ id }}",
|
||||
"item.edit.public.success": "The item is now public",
|
||||
|
||||
"item.edit.reinstate.cancel": "Cancel",
|
||||
"item.edit.reinstate.confirm": "Reinstate",
|
||||
"item.edit.reinstate.description": "Are you sure this item should be reinstated to the archive?",
|
||||
"item.edit.reinstate.error": "An error occurred while reinstating the item",
|
||||
"item.edit.reinstate.header": "Reinstate item: {{ id }}",
|
||||
"item.edit.reinstate.success": "The item was reinstated successfully",
|
||||
|
||||
"item.edit.relationships.discard-button": "Discard",
|
||||
"item.edit.relationships.edit.buttons.remove": "Remove",
|
||||
"item.edit.relationships.edit.buttons.undo": "Undo changes",
|
||||
"item.edit.relationships.notifications.discarded.content": "Your changes were discarded. To reinstate your changes click the 'Undo' button",
|
||||
"item.edit.relationships.notifications.discarded.title": "Changes discarded",
|
||||
"item.edit.relationships.notifications.failed.title": "Error deleting relationship",
|
||||
"item.edit.relationships.notifications.outdated.content": "The item you're currently working on has been changed by another user. Your current changes are discarded to prevent conflicts",
|
||||
"item.edit.relationships.notifications.outdated.title": "Changes outdated",
|
||||
"item.edit.relationships.notifications.saved.content": "Your changes to this item's relationships were saved.",
|
||||
"item.edit.relationships.notifications.saved.title": "Relationships saved",
|
||||
"item.edit.relationships.reinstate-button": "Undo",
|
||||
"item.edit.relationships.save-button": "Save",
|
||||
|
||||
"item.edit.tabs.bitstreams.head": "Item Bitstreams",
|
||||
"item.edit.tabs.bitstreams.title": "Item Edit - Bitstreams",
|
||||
"item.edit.tabs.curate.head": "Curate",
|
||||
"item.edit.tabs.curate.title": "Item Edit - Curate",
|
||||
"item.edit.tabs.metadata.head": "Item Metadata",
|
||||
"item.edit.tabs.metadata.title": "Item Edit - Metadata",
|
||||
"item.edit.tabs.relationships.head": "Item Relationships",
|
||||
"item.edit.tabs.relationships.title": "Item Edit - Relationships",
|
||||
"item.edit.tabs.status.buttons.authorizations.button": "Authorizations...",
|
||||
"item.edit.tabs.status.buttons.authorizations.label": "Edit item's authorization policies",
|
||||
"item.edit.tabs.status.buttons.delete.button": "Permanently delete",
|
||||
@@ -289,12 +418,14 @@
|
||||
"item.edit.tabs.status.title": "Item Edit - Status",
|
||||
"item.edit.tabs.view.head": "View Item",
|
||||
"item.edit.tabs.view.title": "Item Edit - View",
|
||||
|
||||
"item.edit.withdraw.cancel": "Cancel",
|
||||
"item.edit.withdraw.confirm": "Withdraw",
|
||||
"item.edit.withdraw.description": "Are you sure this item should be withdrawn from the archive?",
|
||||
"item.edit.withdraw.error": "An error occurred while withdrawing the item",
|
||||
"item.edit.withdraw.header": "Withdraw item: {{ id }}",
|
||||
"item.edit.withdraw.success": "The item was withdrawn successfully",
|
||||
|
||||
"item.page.abstract": "Abstract",
|
||||
"item.page.author": "Authors",
|
||||
"item.page.citation": "Citation",
|
||||
@@ -312,10 +443,13 @@
|
||||
"item.page.person.search.title": "Articles by this author",
|
||||
"item.page.subject": "Keywords",
|
||||
"item.page.uri": "URI",
|
||||
|
||||
"item.select.confirm": "Confirm selected",
|
||||
"item.select.empty": "No items to show",
|
||||
"item.select.table.author": "Author",
|
||||
"item.select.table.collection": "Collection",
|
||||
"item.select.table.title": "Title",
|
||||
|
||||
"journal.listelement.badge": "Journal",
|
||||
"journal.page.description": "Description",
|
||||
"journal.page.editor": "Editor-in-Chief",
|
||||
@@ -324,6 +458,7 @@
|
||||
"journal.page.titleprefix": "Journal: ",
|
||||
"journal.search.results.head": "Journal Search Results",
|
||||
"journal.search.title": "DSpace Angular :: Journal Search",
|
||||
|
||||
"journalissue.listelement.badge": "Journal Issue",
|
||||
"journalissue.page.description": "Description",
|
||||
"journalissue.page.issuedate": "Issue Date",
|
||||
@@ -332,17 +467,21 @@
|
||||
"journalissue.page.keyword": "Keywords",
|
||||
"journalissue.page.number": "Number",
|
||||
"journalissue.page.titleprefix": "Journal Issue: ",
|
||||
|
||||
"journalvolume.listelement.badge": "Journal Volume",
|
||||
"journalvolume.page.description": "Description",
|
||||
"journalvolume.page.issuedate": "Issue Date",
|
||||
"journalvolume.page.titleprefix": "Journal Volume: ",
|
||||
"journalvolume.page.volume": "Volume",
|
||||
|
||||
"loading.browse-by": "Loading items...",
|
||||
"loading.browse-by-page": "Loading page...",
|
||||
"loading.collection": "Loading collection...",
|
||||
"loading.collections": "Loading collections...",
|
||||
"loading.community": "Loading community...",
|
||||
"loading.default": "Loading...",
|
||||
"loading.item": "Loading item...",
|
||||
"loading.items": "Loading items...",
|
||||
"loading.mydspace-results": "Loading items...",
|
||||
"loading.objects": "Loading...",
|
||||
"loading.recent-submissions": "Loading recent submissions...",
|
||||
@@ -350,6 +489,7 @@
|
||||
"loading.sub-collections": "Loading sub-collections...",
|
||||
"loading.sub-communities": "Loading sub-communities...",
|
||||
"loading.top-level-communities": "Loading top-level communities...",
|
||||
|
||||
"login.form.email": "Email address",
|
||||
"login.form.forgot-password": "Have you forgotten your password?",
|
||||
"login.form.header": "Please log in to DSpace",
|
||||
@@ -357,15 +497,19 @@
|
||||
"login.form.password": "Password",
|
||||
"login.form.submit": "Log in",
|
||||
"login.title": "Login",
|
||||
|
||||
"logout.form.header": "Log out from DSpace",
|
||||
"logout.form.submit": "Log out",
|
||||
"logout.title": "Logout",
|
||||
|
||||
"menu.header.admin": "Admin",
|
||||
"menu.header.image.logo": "Repository logo",
|
||||
|
||||
"menu.section.access_control": "Access Control",
|
||||
"menu.section.access_control_authorizations": "Authorizations",
|
||||
"menu.section.access_control_groups": "Groups",
|
||||
"menu.section.access_control_people": "People",
|
||||
|
||||
"menu.section.browse_community": "This Community",
|
||||
"menu.section.browse_community_by_author": "By Author",
|
||||
"menu.section.browse_community_by_issue_date": "By Issue Date",
|
||||
@@ -376,21 +520,26 @@
|
||||
"menu.section.browse_global_by_subject": "By Subject",
|
||||
"menu.section.browse_global_by_title": "By Title",
|
||||
"menu.section.browse_global_communities_and_collections": "Communities & Collections",
|
||||
|
||||
"menu.section.control_panel": "Control Panel",
|
||||
"menu.section.curation_task": "Curation Task",
|
||||
|
||||
"menu.section.edit": "Edit",
|
||||
"menu.section.edit_collection": "Collection",
|
||||
"menu.section.edit_community": "Community",
|
||||
"menu.section.edit_item": "Item",
|
||||
|
||||
"menu.section.export": "Export",
|
||||
"menu.section.export_collection": "Collection",
|
||||
"menu.section.export_community": "Community",
|
||||
"menu.section.export_item": "Item",
|
||||
"menu.section.export_metadata": "Metadata",
|
||||
|
||||
"menu.section.find": "Find",
|
||||
"menu.section.find_items": "Items",
|
||||
"menu.section.find_private_items": "Private Items",
|
||||
"menu.section.find_withdrawn_items": "Withdrawn Items",
|
||||
|
||||
"menu.section.icon.access_control": "Access Control menu section",
|
||||
"menu.section.icon.control_panel": "Control Panel menu section",
|
||||
"menu.section.icon.curation_task": "Curation Task menu section",
|
||||
@@ -403,20 +552,27 @@
|
||||
"menu.section.icon.registries": "Registries menu section",
|
||||
"menu.section.icon.statistics_task": "Statistics Task menu section",
|
||||
"menu.section.icon.unpin": "Unpin sidebar",
|
||||
|
||||
"menu.section.import": "Import",
|
||||
"menu.section.import_batch": "Batch Import (ZIP)",
|
||||
"menu.section.import_metadata": "Metadata",
|
||||
|
||||
"menu.section.new": "New",
|
||||
"menu.section.new_collection": "Collection",
|
||||
"menu.section.new_community": "Community",
|
||||
"menu.section.new_item": "Item",
|
||||
"menu.section.new_item_version": "Item Version",
|
||||
|
||||
"menu.section.pin": "Pin sidebar",
|
||||
"menu.section.unpin": "Unpin sidebar",
|
||||
|
||||
"menu.section.registries": "Registries",
|
||||
"menu.section.registries_format": "Format",
|
||||
"menu.section.registries_metadata": "Metadata",
|
||||
|
||||
"menu.section.statistics": "Statistics",
|
||||
"menu.section.statistics_task": "Statistics Task",
|
||||
|
||||
"menu.section.toggle.access_control": "Toggle Access Control section",
|
||||
"menu.section.toggle.control_panel": "Toggle Control Panel section",
|
||||
"menu.section.toggle.curation_task": "Toggle Curation Task section",
|
||||
@@ -427,7 +583,7 @@
|
||||
"menu.section.toggle.new": "Toggle New section",
|
||||
"menu.section.toggle.registries": "Toggle Registries section",
|
||||
"menu.section.toggle.statistics_task": "Toggle Statistics Task section",
|
||||
"menu.section.unpin": "Unpin sidebar",
|
||||
|
||||
"mydspace.description": "",
|
||||
"mydspace.general.text-here": "HERE",
|
||||
"mydspace.messages.controller-help": "Select this option to send a message to item's submitter.",
|
||||
@@ -465,6 +621,7 @@
|
||||
"mydspace.upload.upload-multiple-successful": "{{qty}} new workspace items created.",
|
||||
"mydspace.upload.upload-successful": "New workspace item created. Click {{here}} for edit it.",
|
||||
"mydspace.view-btn": "View",
|
||||
|
||||
"nav.browse.header": "All of DSpace",
|
||||
"nav.community-browse.header": "By Community",
|
||||
"nav.language": "Language switch",
|
||||
@@ -473,6 +630,7 @@
|
||||
"nav.mydspace": "MyDSpace",
|
||||
"nav.search": "Search",
|
||||
"nav.statistics.header": "Statistics",
|
||||
|
||||
"orgunit.listelement.badge": "Organizational Unit",
|
||||
"orgunit.page.city": "City",
|
||||
"orgunit.page.country": "Country",
|
||||
@@ -480,10 +638,12 @@
|
||||
"orgunit.page.description": "Description",
|
||||
"orgunit.page.id": "ID",
|
||||
"orgunit.page.titleprefix": "Organizational Unit: ",
|
||||
|
||||
"pagination.results-per-page": "Results Per Page",
|
||||
"pagination.showing.detail": "{{ range }} of {{ total }}",
|
||||
"pagination.showing.label": "Now showing ",
|
||||
"pagination.sort-direction": "Sort Options",
|
||||
|
||||
"person.listelement.badge": "Person",
|
||||
"person.page.birthdate": "Birth Date",
|
||||
"person.page.email": "Email Address",
|
||||
@@ -496,6 +656,7 @@
|
||||
"person.page.titleprefix": "Person: ",
|
||||
"person.search.results.head": "Person Search Results",
|
||||
"person.search.title": "DSpace Angular :: Person Search",
|
||||
|
||||
"project.listelement.badge": "Research Project",
|
||||
"project.page.contributor": "Contributors",
|
||||
"project.page.description": "Description",
|
||||
@@ -505,6 +666,7 @@
|
||||
"project.page.keyword": "Keywords",
|
||||
"project.page.status": "Status",
|
||||
"project.page.titleprefix": "Research Project: ",
|
||||
|
||||
"publication.listelement.badge": "Publication",
|
||||
"publication.page.description": "Description",
|
||||
"publication.page.journal-issn": "Journal ISSN",
|
||||
@@ -514,6 +676,7 @@
|
||||
"publication.page.volume-title": "Volume Title",
|
||||
"publication.search.results.head": "Publication Search Results",
|
||||
"publication.search.title": "DSpace Angular :: Publication Search",
|
||||
|
||||
"relationships.isAuthorOf": "Authors",
|
||||
"relationships.isIssueOf": "Journal Issues",
|
||||
"relationships.isJournalIssueOf": "Journal Issue",
|
||||
@@ -526,7 +689,11 @@
|
||||
"relationships.isSingleJournalOf": "Journal",
|
||||
"relationships.isSingleVolumeOf": "Journal Volume",
|
||||
"relationships.isVolumeOf": "Journal Volumes",
|
||||
|
||||
"search.description": "",
|
||||
"search.switch-configuration.title": "Show",
|
||||
"search.title": "DSpace Angular :: Search",
|
||||
|
||||
"search.filters.applied.f.author": "Author",
|
||||
"search.filters.applied.f.dateIssued.max": "End date",
|
||||
"search.filters.applied.f.dateIssued.min": "Start date",
|
||||
@@ -537,6 +704,7 @@
|
||||
"search.filters.applied.f.namedresourcetype": "Status",
|
||||
"search.filters.applied.f.subject": "Subject",
|
||||
"search.filters.applied.f.submitter": "Submitter",
|
||||
|
||||
"search.filters.filter.author.head": "Author",
|
||||
"search.filters.filter.author.placeholder": "Author name",
|
||||
"search.filters.filter.birthDate.head": "Birth Date",
|
||||
@@ -581,14 +749,18 @@
|
||||
"search.filters.filter.subject.placeholder": "Subject",
|
||||
"search.filters.filter.submitter.head": "Submitter",
|
||||
"search.filters.filter.submitter.placeholder": "Submitter",
|
||||
|
||||
"search.filters.head": "Filters",
|
||||
"search.filters.reset": "Reset filters",
|
||||
|
||||
"search.form.search": "Search",
|
||||
"search.form.search_dspace": "Search DSpace",
|
||||
"search.form.search_mydspace": "Search MyDSpace",
|
||||
|
||||
"search.results.head": "Search Results",
|
||||
"search.results.no-results": "Your search returned no results. Having trouble finding what you're looking for? Try putting",
|
||||
"search.results.no-results-link": "quotes around it",
|
||||
|
||||
"search.sidebar.close": "Back to results",
|
||||
"search.sidebar.filters.title": "Filters",
|
||||
"search.sidebar.open": "Search Tools",
|
||||
@@ -596,14 +768,15 @@
|
||||
"search.sidebar.settings.rpp": "Results per page",
|
||||
"search.sidebar.settings.sort-by": "Sort By",
|
||||
"search.sidebar.settings.title": "Settings",
|
||||
"search.switch-configuration.title": "Show",
|
||||
"search.title": "DSpace Angular :: Search",
|
||||
|
||||
"search.view-switch.show-detail": "Show detail",
|
||||
"search.view-switch.show-grid": "Show as grid",
|
||||
"search.view-switch.show-list": "Show as list",
|
||||
|
||||
"sorting.dc.title.ASC": "Title Ascending",
|
||||
"sorting.dc.title.DESC": "Title Descending",
|
||||
"sorting.score.DESC": "Relevance",
|
||||
|
||||
"submission.edit.title": "Edit Submission",
|
||||
"submission.general.cannot_submit": "You have not the privilege to make a new submission.",
|
||||
"submission.general.deposit": "Deposit",
|
||||
@@ -614,7 +787,7 @@
|
||||
"submission.general.discard.submit": "Discard",
|
||||
"submission.general.save": "Save",
|
||||
"submission.general.save-later": "Save for later",
|
||||
"submission.mydspace": {},
|
||||
|
||||
"submission.sections.general.add-more": "Add more",
|
||||
"submission.sections.general.collection": "Collection",
|
||||
"submission.sections.general.deposit_error_notice": "There was an issue when submitting the item, please try again later.",
|
||||
@@ -629,6 +802,7 @@
|
||||
"submission.sections.general.save_success_notice": "Submission saved successfully.",
|
||||
"submission.sections.general.search-collection": "Search for a collection",
|
||||
"submission.sections.general.sections_not_valid": "There are incomplete sections.",
|
||||
|
||||
"submission.sections.submit.progressbar.cclicense": "Creative commons license",
|
||||
"submission.sections.submit.progressbar.describe.recycle": "Recycle",
|
||||
"submission.sections.submit.progressbar.describe.stepcustom": "Describe",
|
||||
@@ -637,6 +811,7 @@
|
||||
"submission.sections.submit.progressbar.detect-duplicate": "Potential duplicates",
|
||||
"submission.sections.submit.progressbar.license": "Deposit license",
|
||||
"submission.sections.submit.progressbar.upload": "Upload files",
|
||||
|
||||
"submission.sections.upload.delete.confirm.cancel": "Cancel",
|
||||
"submission.sections.upload.delete.confirm.info": "This operation can't be undone. Are you sure?",
|
||||
"submission.sections.upload.delete.confirm.submit": "Yes, I'm sure",
|
||||
@@ -660,13 +835,16 @@
|
||||
"submission.sections.upload.undo": "Cancel",
|
||||
"submission.sections.upload.upload-failed": "Upload failed",
|
||||
"submission.sections.upload.upload-successful": "Upload successful",
|
||||
|
||||
"submission.submit.title": "Submission",
|
||||
|
||||
"submission.workflow.generic.delete": "Delete",
|
||||
"submission.workflow.generic.delete-help": "If you would to discard this item, select \"Delete\". You will then be asked to confirm it.",
|
||||
"submission.workflow.generic.edit": "Edit",
|
||||
"submission.workflow.generic.edit-help": "Select this option to change the item's metadata.",
|
||||
"submission.workflow.generic.view": "View",
|
||||
"submission.workflow.generic.view-help": "Select this option to view the item's metadata.",
|
||||
|
||||
"submission.workflow.tasks.claimed.approve": "Approve",
|
||||
"submission.workflow.tasks.claimed.approve_help": "If you have reviewed the item and it is suitable for inclusion in the collection, select \"Approve\".",
|
||||
"submission.workflow.tasks.claimed.edit": "Edit",
|
||||
@@ -679,18 +857,22 @@
|
||||
"submission.workflow.tasks.claimed.reject_help": "If you have reviewed the item and found it is <strong>not</strong> suitable for inclusion in the collection, select \"Reject\". You will then be asked to enter a message indicating why the item is unsuitable, and whether the submitter should change something and resubmit.",
|
||||
"submission.workflow.tasks.claimed.return": "Return to pool",
|
||||
"submission.workflow.tasks.claimed.return_help": "Return the task to the pool so that another user may perform the task.",
|
||||
|
||||
"submission.workflow.tasks.generic.error": "Error occurred during operation...",
|
||||
"submission.workflow.tasks.generic.processing": "Processing...",
|
||||
"submission.workflow.tasks.generic.submitter": "Submitter",
|
||||
"submission.workflow.tasks.generic.success": "Operation successful",
|
||||
|
||||
"submission.workflow.tasks.pool.claim": "Claim",
|
||||
"submission.workflow.tasks.pool.claim_help": "Assign this task to yourself.",
|
||||
"submission.workflow.tasks.pool.hide-detail": "Hide detail",
|
||||
"submission.workflow.tasks.pool.show-detail": "Show detail",
|
||||
|
||||
"title": "DSpace",
|
||||
|
||||
"uploader.browse": "browse",
|
||||
"uploader.drag-message": "Drag & Drop your files here",
|
||||
"uploader.or": ", or",
|
||||
"uploader.processing": "Processing",
|
||||
"uploader.queue-lenght": "Queue length"
|
||||
"uploader.queue-length": "Queue length",
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
"404.help": "De pagina die u zoekt kan niet gevonden worden. De pagina werd mogelijk verplaatst of verwijderd. U kan onderstaande knop gebruiken om terug naar de homepagina te gaan. ",
|
||||
"404.link.home-page": "Terug naar de homepagina",
|
||||
"404.page-not-found": "Pagina niet gevonden",
|
||||
|
||||
"admin.registries.bitstream-formats.description": "Deze lijst van Bitstream formaten biedt informatie over de formaten die in deze repository zijn toegelaten en op welke manier ze ondersteund worden. De term Bitstream wordt in DSpace gebruikt om een bestand aan te duiden dat samen met metadata onderdeel uitmaakt van een item. De naam bitstream duidt op het feit dat het bestand achterliggend wordt opgeslaan zonder bestandsextensie.",
|
||||
"admin.registries.bitstream-formats.formats.no-items": "Er kunnen geen bitstreamformaten getoond worden.",
|
||||
"admin.registries.bitstream-formats.formats.table.internal": "intern",
|
||||
@@ -13,6 +14,7 @@
|
||||
"admin.registries.bitstream-formats.formats.table.supportLevel.head": "Ondersteuning",
|
||||
"admin.registries.bitstream-formats.head": "Bitstream Formaat Register",
|
||||
"admin.registries.bitstream-formats.title": "DSpace Angular :: Bitstream Formaat Register",
|
||||
|
||||
"admin.registries.metadata.description": "Het metadataregister omvat de lijst van alle metadatavelden die beschikbaar zijn in het systeem. Deze velden kunnen verspreid zijn over verschillende metadataschema's. Het qualified Dublin Core schema (dc) is een verplicht schema en kan niet worden verwijderd.",
|
||||
"admin.registries.metadata.head": "Metadata Register",
|
||||
"admin.registries.metadata.schemas.no-items": "Er kunnen geen metadataschema's getoond worden.",
|
||||
@@ -20,6 +22,7 @@
|
||||
"admin.registries.metadata.schemas.table.name": "Naam",
|
||||
"admin.registries.metadata.schemas.table.namespace": "Naamruimte",
|
||||
"admin.registries.metadata.title": "DSpace Angular :: Metadata Register",
|
||||
|
||||
"admin.registries.schema.description": "Dit is het metadataschema voor \"{{namespace}}\".",
|
||||
"admin.registries.schema.fields.head": "Schema metadatavelden",
|
||||
"admin.registries.schema.fields.no-items": "Er kunnen geen metadatavelden getoond worden.",
|
||||
@@ -27,15 +30,20 @@
|
||||
"admin.registries.schema.fields.table.scopenote": "Opmerking over bereik",
|
||||
"admin.registries.schema.head": "Metadata Schema",
|
||||
"admin.registries.schema.title": "DSpace Angular :: Metadata Schema Register",
|
||||
|
||||
"auth.errors.invalid-user": "Ongeldig e-mailadres of wachtwoord.",
|
||||
"auth.messages.expired": "Uw sessie is vervallen. Gelieve opnieuw aan te melden.",
|
||||
|
||||
"browse.title": "Verken {{ collection }} volgens {{ field }} {{ value }}",
|
||||
|
||||
"collection.page.browse.recent.head": "Recent toegevoegd",
|
||||
"collection.page.license": "Licentie",
|
||||
"collection.page.news": "Nieuws",
|
||||
|
||||
"community.page.license": "Licentie",
|
||||
"community.page.news": "Nieuws",
|
||||
"community.sub-collection-list.head": "Collecties in deze Community",
|
||||
|
||||
"error.browse-by": "Fout bij het ophalen van items",
|
||||
"error.collection": "Fout bij het ophalen van een collectie",
|
||||
"error.community": "Fout bij het ophalen van een community",
|
||||
@@ -48,9 +56,11 @@
|
||||
"error.top-level-communities": "Fout bij het inladen van communities op het hoogste niveau",
|
||||
"error.validation.license.notgranted": "U moet de invoerlicentie goedkeuren om de invoer af te werken. Indien u deze licentie momenteel niet kan of mag goedkeuren, kan u uw werk opslaan en de invoer later afwerken. U kunt dit nieuwe item ook verwijderen indien u niet voldoet aan de vereisten van de invoerlicentie.",
|
||||
"error.validation.pattern": "Deze invoer is niet toegelaten volgens dit patroon: {{ pattern }}.",
|
||||
|
||||
"footer.copyright": "copyright © 2002-{{ year }}",
|
||||
"footer.link.dspace": "DSpace software",
|
||||
"footer.link.duraspace": "DuraSpace",
|
||||
|
||||
"form.cancel": "Annuleer",
|
||||
"form.first-name": "Voornaam",
|
||||
"form.group-collapse": "Inklappen",
|
||||
@@ -64,10 +74,12 @@
|
||||
"form.remove": "Verwijder",
|
||||
"form.search": "Zoek",
|
||||
"form.submit": "Verstuur",
|
||||
|
||||
"home.description": "",
|
||||
"home.title": "DSpace Angular :: Home",
|
||||
"home.top-level-communities.head": "Communities in DSpace",
|
||||
"home.top-level-communities.help": "Selecteer een community om diens collecties te verkennen.",
|
||||
|
||||
"item.page.abstract": "Abstract",
|
||||
"item.page.author": "Auteur",
|
||||
"item.page.collections": "Collecties",
|
||||
@@ -81,6 +93,7 @@
|
||||
"item.page.link.full": "Volledige itemweergave",
|
||||
"item.page.link.simple": "Eenvoudige itemweergave",
|
||||
"item.page.uri": "URI",
|
||||
|
||||
"loading.browse-by": "Items worden ingeladen...",
|
||||
"loading.collection": "Collectie wordt ingeladen...",
|
||||
"loading.community": "Community wordt ingeladen...",
|
||||
@@ -91,6 +104,7 @@
|
||||
"loading.search-results": "Zoekresultaten worden ingeladen...",
|
||||
"loading.sub-collections": "De sub-collecties worden ingeladen...",
|
||||
"loading.top-level-communities": "Inladen van de Communities op het hoogste niveau...",
|
||||
|
||||
"login.form.email": "Email adres",
|
||||
"login.form.forgot-password": "Bent u uw wachtwoord vergeten?",
|
||||
"login.form.header": "Gelieve in te loggen in DSpace",
|
||||
@@ -98,17 +112,23 @@
|
||||
"login.form.password": "Wachtwoord",
|
||||
"login.form.submit": "Aanmelden",
|
||||
"login.title": "Aanmelden",
|
||||
|
||||
"logout.form.header": "Afmelden in DSpace",
|
||||
"logout.form.submit": "Afmelden",
|
||||
"logout.title": "Afmelden",
|
||||
|
||||
"nav.home": "Home",
|
||||
"nav.login": "Log In",
|
||||
"nav.logout": "Log Uit",
|
||||
|
||||
"pagination.results-per-page": "Resultaten per pagina",
|
||||
"pagination.showing.detail": "{{ range }} van {{ total }}",
|
||||
"pagination.showing.label": "Resultaten ",
|
||||
"pagination.sort-direction": "Sorteermogelijkheden",
|
||||
|
||||
"search.description": "",
|
||||
"search.title": "DSpace Angular :: Zoek",
|
||||
|
||||
"search.filters.applied.f.author": "Auteur",
|
||||
"search.filters.applied.f.dateIssued.max": "Einddatum",
|
||||
"search.filters.applied.f.dateIssued.min": "Startdatum",
|
||||
@@ -126,12 +146,16 @@
|
||||
"search.filters.filter.show-more": "Toon meer",
|
||||
"search.filters.filter.subject.head": "Onderwerp",
|
||||
"search.filters.filter.subject.placeholder": "Onderwerp",
|
||||
|
||||
"search.filters.head": "Filters",
|
||||
"search.filters.reset": "Filters verwijderen",
|
||||
|
||||
"search.form.search": "Zoek",
|
||||
"search.form.search_dspace": "Zoek in DSpace",
|
||||
|
||||
"search.results.head": "Zoekresultaten",
|
||||
"search.results.no-results": "Er waren geen resultaten voor deze zoekopdracht",
|
||||
|
||||
"search.sidebar.close": "Terug naar de resultaten",
|
||||
"search.sidebar.filters.title": "Filters",
|
||||
"search.sidebar.open": "Zoek Tools",
|
||||
@@ -139,11 +163,13 @@
|
||||
"search.sidebar.settings.rpp": "Resultaten per pagina",
|
||||
"search.sidebar.settings.sort-by": "Sorteer volgens",
|
||||
"search.sidebar.settings.title": "Instellingen",
|
||||
"search.title": "DSpace Angular :: Zoek",
|
||||
|
||||
"search.view-switch.show-grid": "Toon in raster",
|
||||
"search.view-switch.show-list": "Toon als lijst",
|
||||
|
||||
"sorting.dc.title.ASC": "Oplopend op titel",
|
||||
"sorting.dc.title.DESC": "Aflopend op titel",
|
||||
"sorting.score.DESC": "Relevantie",
|
||||
"title": "DSpace"
|
||||
|
||||
"title": "DSpace",
|
||||
}
|
@@ -2,14 +2,29 @@ import { MetadataRegistryComponent } from './metadata-registry/metadata-registry
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { MetadataSchemaComponent } from './metadata-schema/metadata-schema.component';
|
||||
import { BitstreamFormatsComponent } from './bitstream-formats/bitstream-formats.component';
|
||||
import { URLCombiner } from '../../core/url-combiner/url-combiner';
|
||||
import { getRegistriesModulePath } from '../admin-routing.module';
|
||||
|
||||
const BITSTREAMFORMATS_MODULE_PATH = 'bitstream-formats';
|
||||
|
||||
export function getBitstreamFormatsModulePath() {
|
||||
return new URLCombiner(getRegistriesModulePath(), BITSTREAMFORMATS_MODULE_PATH).toString();
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild([
|
||||
{ path: 'metadata', component: MetadataRegistryComponent, data: { title: 'admin.registries.metadata.title' } },
|
||||
{ path: 'metadata/:schemaName', component: MetadataSchemaComponent, data: { title: 'admin.registries.schema.title' } },
|
||||
{ path: 'bitstream-formats', component: BitstreamFormatsComponent, data: { title: 'admin.registries.bitstream-formats.title' } },
|
||||
{path: 'metadata', component: MetadataRegistryComponent, data: {title: 'admin.registries.metadata.title'}},
|
||||
{
|
||||
path: 'metadata/:schemaName',
|
||||
component: MetadataSchemaComponent,
|
||||
data: {title: 'admin.registries.schema.title'}
|
||||
},
|
||||
{
|
||||
path: BITSTREAMFORMATS_MODULE_PATH,
|
||||
loadChildren: './bitstream-formats/bitstream-formats.module#BitstreamFormatsModule',
|
||||
data: {title: 'admin.registries.bitstream-formats.title'}
|
||||
},
|
||||
])
|
||||
]
|
||||
})
|
||||
|
@@ -5,10 +5,10 @@ import { CommonModule } from '@angular/common';
|
||||
import { MetadataSchemaComponent } from './metadata-schema/metadata-schema.component';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { BitstreamFormatsComponent } from './bitstream-formats/bitstream-formats.component';
|
||||
import { SharedModule } from '../../shared/shared.module';
|
||||
import { MetadataSchemaFormComponent } from './metadata-registry/metadata-schema-form/metadata-schema-form.component';
|
||||
import {MetadataFieldFormComponent} from './metadata-schema/metadata-field-form/metadata-field-form.component';
|
||||
import { MetadataFieldFormComponent } from './metadata-schema/metadata-field-form/metadata-field-form.component';
|
||||
import { BitstreamFormatsModule } from './bitstream-formats/bitstream-formats.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -16,12 +16,12 @@ import {MetadataFieldFormComponent} from './metadata-schema/metadata-field-form/
|
||||
SharedModule,
|
||||
RouterModule,
|
||||
TranslateModule,
|
||||
BitstreamFormatsModule,
|
||||
AdminRegistriesRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
MetadataRegistryComponent,
|
||||
MetadataSchemaComponent,
|
||||
BitstreamFormatsComponent,
|
||||
MetadataSchemaFormComponent,
|
||||
MetadataFieldFormComponent
|
||||
],
|
||||
|
@@ -0,0 +1,11 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-4">
|
||||
<h2 id="sub-header"
|
||||
class="border-bottom mb-2">{{ 'admin.registries.bitstream-formats.create.new' | translate }}</h2>
|
||||
|
||||
<ds-bitstream-format-form (updatedFormat)="createBitstreamFormat($event)"></ds-bitstream-format-form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,106 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Router } from '@angular/router';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { RouterStub } from '../../../../shared/testing/router-stub';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../../shared/testing/notifications-service-stub';
|
||||
import { BitstreamFormatDataService } from '../../../../core/data/bitstream-format-data.service';
|
||||
import { RestResponse } from '../../../../core/cache/response.models';
|
||||
import { BitstreamFormat } from '../../../../core/shared/bitstream-format.model';
|
||||
import { BitstreamFormatSupportLevel } from '../../../../core/shared/bitstream-format-support-level';
|
||||
import { ResourceType } from '../../../../core/shared/resource-type';
|
||||
import { AddBitstreamFormatComponent } from './add-bitstream-format.component';
|
||||
|
||||
describe('AddBitstreamFormatComponent', () => {
|
||||
let comp: AddBitstreamFormatComponent;
|
||||
let fixture: ComponentFixture<AddBitstreamFormatComponent>;
|
||||
|
||||
const bitstreamFormat = new BitstreamFormat();
|
||||
bitstreamFormat.uuid = 'test-uuid-1';
|
||||
bitstreamFormat.id = 'test-uuid-1';
|
||||
bitstreamFormat.shortDescription = 'Unknown';
|
||||
bitstreamFormat.description = 'Unknown data format';
|
||||
bitstreamFormat.mimetype = 'application/octet-stream';
|
||||
bitstreamFormat.supportLevel = BitstreamFormatSupportLevel.Unknown;
|
||||
bitstreamFormat.internal = false;
|
||||
bitstreamFormat.extensions = null;
|
||||
|
||||
let router;
|
||||
let notificationService: NotificationsServiceStub;
|
||||
let bitstreamFormatDataService: BitstreamFormatDataService;
|
||||
|
||||
const initAsync = () => {
|
||||
router = new RouterStub();
|
||||
notificationService = new NotificationsServiceStub();
|
||||
bitstreamFormatDataService = jasmine.createSpyObj('bitstreamFormatDataService', {
|
||||
createBitstreamFormat: observableOf(new RestResponse(true, 200, 'Success')),
|
||||
clearBitStreamFormatRequests: observableOf(null)
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [AddBitstreamFormatComponent],
|
||||
providers: [
|
||||
{provide: Router, useValue: router},
|
||||
{provide: NotificationsService, useValue: notificationService},
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatDataService},
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
}).compileComponents();
|
||||
};
|
||||
|
||||
const initBeforeEach = () => {
|
||||
fixture = TestBed.createComponent(AddBitstreamFormatComponent);
|
||||
comp = fixture.componentInstance;
|
||||
|
||||
fixture.detectChanges();
|
||||
};
|
||||
|
||||
describe('createBitstreamFormat success', () => {
|
||||
beforeEach(async(initAsync));
|
||||
beforeEach(initBeforeEach);
|
||||
it('should send the updated form to the service, show a notification and navigate to ', () => {
|
||||
comp.createBitstreamFormat(bitstreamFormat);
|
||||
|
||||
expect(bitstreamFormatDataService.createBitstreamFormat).toHaveBeenCalledWith(bitstreamFormat);
|
||||
expect(notificationService.success).toHaveBeenCalled();
|
||||
expect(router.navigate).toHaveBeenCalledWith(['/admin/registries/bitstream-formats']);
|
||||
|
||||
});
|
||||
});
|
||||
describe('createBitstreamFormat error', () => {
|
||||
beforeEach(async(() => {
|
||||
router = new RouterStub();
|
||||
notificationService = new NotificationsServiceStub();
|
||||
bitstreamFormatDataService = jasmine.createSpyObj('bitstreamFormatDataService', {
|
||||
createBitstreamFormat: observableOf(new RestResponse(false, 400, 'Bad Request')),
|
||||
clearBitStreamFormatRequests: observableOf(null)
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [AddBitstreamFormatComponent],
|
||||
providers: [
|
||||
{provide: Router, useValue: router},
|
||||
{provide: NotificationsService, useValue: notificationService},
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatDataService},
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
}).compileComponents();
|
||||
}));
|
||||
beforeEach(initBeforeEach);
|
||||
it('should send the updated form to the service, show a notification and navigate to ', () => {
|
||||
comp.createBitstreamFormat(bitstreamFormat);
|
||||
|
||||
expect(bitstreamFormatDataService.createBitstreamFormat).toHaveBeenCalledWith(bitstreamFormat);
|
||||
expect(notificationService.error).toHaveBeenCalled();
|
||||
expect(router.navigate).not.toHaveBeenCalled();
|
||||
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,49 @@
|
||||
import { take } from 'rxjs/operators';
|
||||
import { Router } from '@angular/router';
|
||||
import { Component } from '@angular/core';
|
||||
import { BitstreamFormat } from '../../../../core/shared/bitstream-format.model';
|
||||
import { BitstreamFormatDataService } from '../../../../core/data/bitstream-format-data.service';
|
||||
import { RestResponse } from '../../../../core/cache/response.models';
|
||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||
import { getBitstreamFormatsModulePath } from '../../admin-registries-routing.module';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
/**
|
||||
* This component renders the page to create a new bitstream format.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ds-add-bitstream-format',
|
||||
templateUrl: './add-bitstream-format.component.html',
|
||||
})
|
||||
export class AddBitstreamFormatComponent {
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private notificationService: NotificationsService,
|
||||
private translateService: TranslateService,
|
||||
private bitstreamFormatDataService: BitstreamFormatDataService,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new bitstream format based on the provided bitstream format emitted by the form.
|
||||
* When successful, a success notification will be shown and the user will be navigated back to the overview page.
|
||||
* When failed, an error notification will be shown.
|
||||
* @param bitstreamFormat
|
||||
*/
|
||||
createBitstreamFormat(bitstreamFormat: BitstreamFormat) {
|
||||
this.bitstreamFormatDataService.createBitstreamFormat(bitstreamFormat).pipe(take(1)
|
||||
).subscribe((response: RestResponse) => {
|
||||
if (response.isSuccessful) {
|
||||
this.notificationService.success(this.translateService.get('admin.registries.bitstream-formats.create.success.head'),
|
||||
this.translateService.get('admin.registries.bitstream-formats.create.success.content'));
|
||||
this.router.navigate([getBitstreamFormatsModulePath()]);
|
||||
this.bitstreamFormatDataService.clearBitStreamFormatRequests().subscribe();
|
||||
} else {
|
||||
this.notificationService.error(this.translateService.get('admin.registries.bitstream-formats.create.failure.head'),
|
||||
this.translateService.get('admin.registries.bitstream-formats.create.failure.content'));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
import { Action } from '@ngrx/store';
|
||||
import { type } from '../../../shared/ngrx/type';
|
||||
import { BitstreamFormat } from '../../../core/shared/bitstream-format.model';
|
||||
|
||||
/**
|
||||
* For each action type in an action group, make a simple
|
||||
* enum object for all of this group's action types.
|
||||
*
|
||||
* The 'type' utility function coerces strings into string
|
||||
* literal types and runs a simple check to guarantee all
|
||||
* action types in the application are unique.
|
||||
*/
|
||||
export const BitstreamFormatsRegistryActionTypes = {
|
||||
|
||||
SELECT_FORMAT: type('dspace/bitstream-formats-registry/SELECT_FORMAT'),
|
||||
DESELECT_FORMAT: type('dspace/bitstream-formats-registry/DESELECT_FORMAT'),
|
||||
DESELECT_ALL_FORMAT: type('dspace/bitstream-formats-registry/DESELECT_ALL_FORMAT')
|
||||
};
|
||||
|
||||
/* tslint:disable:max-classes-per-file */
|
||||
/**
|
||||
* Used to select a single bitstream format in the bitstream format registry
|
||||
*/
|
||||
export class BitstreamFormatsRegistrySelectAction implements Action {
|
||||
type = BitstreamFormatsRegistryActionTypes.SELECT_FORMAT;
|
||||
|
||||
bitstreamFormat: BitstreamFormat;
|
||||
|
||||
constructor(bitstreamFormat: BitstreamFormat) {
|
||||
this.bitstreamFormat = bitstreamFormat;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to deselect a single bitstream format in the bitstream format registry
|
||||
*/
|
||||
export class BitstreamFormatsRegistryDeselectAction implements Action {
|
||||
type = BitstreamFormatsRegistryActionTypes.DESELECT_FORMAT;
|
||||
|
||||
bitstreamFormat: BitstreamFormat;
|
||||
|
||||
constructor(bitstreamFormat: BitstreamFormat) {
|
||||
this.bitstreamFormat = bitstreamFormat;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to deselect all bitstream formats in the bitstream format registry
|
||||
*/
|
||||
export class BitstreamFormatsRegistryDeselectAllAction implements Action {
|
||||
type = BitstreamFormatsRegistryActionTypes.DESELECT_ALL_FORMAT;
|
||||
}
|
||||
|
||||
/* tslint:enable:max-classes-per-file */
|
||||
|
||||
/**
|
||||
* Export a type alias of all actions in this action group
|
||||
* so that reducers can easily compose action types
|
||||
* These are all the actions to perform on the bitstream format registry state
|
||||
*/
|
||||
export type BitstreamFormatsRegistryAction
|
||||
= BitstreamFormatsRegistrySelectAction
|
||||
| BitstreamFormatsRegistryDeselectAction
|
||||
| BitstreamFormatsRegistryDeselectAllAction
|
@@ -0,0 +1,83 @@
|
||||
import { Action } from '@ngrx/store';
|
||||
import { BitstreamFormat } from '../../../core/shared/bitstream-format.model';
|
||||
import { bitstreamFormatReducer, BitstreamFormatRegistryState } from './bitstream-format.reducers';
|
||||
import {
|
||||
BitstreamFormatsRegistryDeselectAction,
|
||||
BitstreamFormatsRegistryDeselectAllAction,
|
||||
BitstreamFormatsRegistrySelectAction
|
||||
} from './bitstream-format.actions';
|
||||
|
||||
const bitstreamFormat1: BitstreamFormat = new BitstreamFormat();
|
||||
bitstreamFormat1.id = 'test-uuid-1';
|
||||
bitstreamFormat1.shortDescription = 'test-short-1';
|
||||
|
||||
const bitstreamFormat2: BitstreamFormat = new BitstreamFormat();
|
||||
bitstreamFormat2.id = 'test-uuid-2';
|
||||
bitstreamFormat2.shortDescription = 'test-short-2';
|
||||
|
||||
const initialState: BitstreamFormatRegistryState = {
|
||||
selectedBitstreamFormats: []
|
||||
};
|
||||
|
||||
const bitstream1SelectedState: BitstreamFormatRegistryState = {
|
||||
selectedBitstreamFormats: [bitstreamFormat1]
|
||||
};
|
||||
|
||||
const bitstream1and2SelectedState: BitstreamFormatRegistryState = {
|
||||
selectedBitstreamFormats: [bitstreamFormat1, bitstreamFormat2]
|
||||
};
|
||||
|
||||
describe('BitstreamFormatReducer', () => {
|
||||
describe('BitstreamFormatsRegistryActionTypes.SELECT_FORMAT', () => {
|
||||
it('should add the format to the list of selected formats when initial list is empty', () => {
|
||||
const state = initialState;
|
||||
const action = new BitstreamFormatsRegistrySelectAction(bitstreamFormat1);
|
||||
const newState = bitstreamFormatReducer(state, action);
|
||||
|
||||
expect(newState).toEqual(bitstream1SelectedState);
|
||||
});
|
||||
it('should add the format to the list of selected formats when formats are already present', () => {
|
||||
const state = bitstream1SelectedState;
|
||||
const action = new BitstreamFormatsRegistrySelectAction(bitstreamFormat2);
|
||||
const newState = bitstreamFormatReducer(state, action);
|
||||
|
||||
expect(newState).toEqual(bitstream1and2SelectedState);
|
||||
});
|
||||
});
|
||||
describe('BitstreamFormatsRegistryActionTypes.DESELECT_FORMAT', () => {
|
||||
it('should deselect a format', () => {
|
||||
const state = bitstream1and2SelectedState;
|
||||
const action = new BitstreamFormatsRegistryDeselectAction(bitstreamFormat2);
|
||||
const newState = bitstreamFormatReducer(state, action);
|
||||
|
||||
expect(newState).toEqual(bitstream1SelectedState);
|
||||
});
|
||||
});
|
||||
describe('BitstreamFormatsRegistryActionTypes.DESELECT_ALL_FORMAT', () => {
|
||||
it('should deselect all formats', () => {
|
||||
const state = bitstream1and2SelectedState;
|
||||
const action = new BitstreamFormatsRegistryDeselectAllAction();
|
||||
const newState = bitstreamFormatReducer(state, action);
|
||||
|
||||
expect(newState).toEqual(initialState);
|
||||
});
|
||||
});
|
||||
describe('Invalid action', () => {
|
||||
it('should return the current state', () => {
|
||||
const state = initialState;
|
||||
const action = new NullAction();
|
||||
|
||||
const newState = bitstreamFormatReducer(state, action);
|
||||
|
||||
expect(newState).toEqual(state);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
class NullAction implements Action {
|
||||
type = null;
|
||||
|
||||
constructor() {
|
||||
// empty constructor
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
import { BitstreamFormat } from '../../../core/shared/bitstream-format.model';
|
||||
import {
|
||||
BitstreamFormatsRegistryAction,
|
||||
BitstreamFormatsRegistryActionTypes,
|
||||
BitstreamFormatsRegistryDeselectAction,
|
||||
BitstreamFormatsRegistrySelectAction
|
||||
} from './bitstream-format.actions';
|
||||
|
||||
/**
|
||||
* The bitstream format registry state.
|
||||
* @interface BitstreamFormatRegistryState
|
||||
*/
|
||||
export interface BitstreamFormatRegistryState {
|
||||
selectedBitstreamFormats: BitstreamFormat[];
|
||||
}
|
||||
|
||||
/**
|
||||
* The initial state.
|
||||
*/
|
||||
const initialState: BitstreamFormatRegistryState = {
|
||||
selectedBitstreamFormats: [],
|
||||
};
|
||||
|
||||
/**
|
||||
* Reducer that handles BitstreamFormatsRegistryActions to modify the bitstream format registry state
|
||||
* @param state The current BitstreamFormatRegistryState
|
||||
* @param action The BitstreamFormatsRegistryAction to perform on the state
|
||||
*/
|
||||
export function bitstreamFormatReducer(state = initialState, action: BitstreamFormatsRegistryAction): BitstreamFormatRegistryState {
|
||||
|
||||
switch (action.type) {
|
||||
|
||||
case BitstreamFormatsRegistryActionTypes.SELECT_FORMAT: {
|
||||
return Object.assign({}, state, {
|
||||
selectedBitstreamFormats: [...state.selectedBitstreamFormats, (action as BitstreamFormatsRegistrySelectAction).bitstreamFormat]
|
||||
});
|
||||
}
|
||||
|
||||
case BitstreamFormatsRegistryActionTypes.DESELECT_FORMAT: {
|
||||
return Object.assign({}, state, {
|
||||
selectedBitstreamFormats: state.selectedBitstreamFormats.filter(
|
||||
(selectedBitstreamFormats) => selectedBitstreamFormats !== (action as BitstreamFormatsRegistryDeselectAction).bitstreamFormat
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
case BitstreamFormatsRegistryActionTypes.DESELECT_ALL_FORMAT: {
|
||||
return Object.assign({}, state, {
|
||||
selectedBitstreamFormats: []
|
||||
});
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { BitstreamFormatsResolver } from './bitstream-formats.resolver';
|
||||
import { EditBitstreamFormatComponent } from './edit-bitstream-format/edit-bitstream-format.component';
|
||||
import { BitstreamFormatsComponent } from './bitstream-formats.component';
|
||||
import { AddBitstreamFormatComponent } from './add-bitstream-format/add-bitstream-format.component';
|
||||
|
||||
const BITSTREAMFORMAT_EDIT_PATH = ':id/edit';
|
||||
const BITSTREAMFORMAT_ADD_PATH = 'add';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild([
|
||||
{
|
||||
path: '',
|
||||
component: BitstreamFormatsComponent
|
||||
},
|
||||
{
|
||||
path: BITSTREAMFORMAT_ADD_PATH,
|
||||
component: AddBitstreamFormatComponent,
|
||||
},
|
||||
{
|
||||
path: BITSTREAMFORMAT_EDIT_PATH,
|
||||
component: EditBitstreamFormatComponent,
|
||||
resolve: {
|
||||
bitstreamFormat: BitstreamFormatsResolver
|
||||
}
|
||||
},
|
||||
])
|
||||
],
|
||||
providers: [
|
||||
BitstreamFormatsResolver,
|
||||
]
|
||||
})
|
||||
export class BitstreamFormatsRoutingModule {
|
||||
|
||||
}
|
@@ -2,13 +2,15 @@
|
||||
<div class="bitstream-formats row">
|
||||
<div class="col-12">
|
||||
|
||||
<h2 id="header" class="border-bottom pb-2">{{'admin.registries.bitstream-formats.head' | translate}}</h2>
|
||||
<h2 id="header" class="border-bottom pb-2 ">{{'admin.registries.bitstream-formats.head' | translate}}</h2>
|
||||
|
||||
<p id="description">{{'admin.registries.bitstream-formats.description' | translate}}</p>
|
||||
<p id="create-new" class="mb-2"><a [routerLink]="'add'" class="btn btn-success">{{'admin.registries.bitstream-formats.create.new' | translate}}</a></p>
|
||||
|
||||
<p id="description" class="pb-2">{{'admin.registries.bitstream-formats.description' | translate}}</p>
|
||||
|
||||
<ds-pagination
|
||||
*ngIf="(bitstreamFormats | async)?.payload?.totalElements > 0"
|
||||
[paginationOptions]="config"
|
||||
[paginationOptions]="pageConfig"
|
||||
[pageInfoState]="(bitstreamFormats | async)?.payload"
|
||||
[collectionSize]="(bitstreamFormats | async)?.payload?.totalElements"
|
||||
[hideGear]="true"
|
||||
@@ -18,25 +20,38 @@
|
||||
<table id="formats" class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{'admin.registries.bitstream-formats.formats.table.name' | translate}}</th>
|
||||
<th scope="col">{{'admin.registries.bitstream-formats.formats.table.mimetype' | translate}}</th>
|
||||
<th scope="col">{{'admin.registries.bitstream-formats.formats.table.supportLevel.head' | translate}}</th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col">{{'admin.registries.bitstream-formats.table.name' | translate}}</th>
|
||||
<th scope="col">{{'admin.registries.bitstream-formats.table.mimetype' | translate}}</th>
|
||||
<th scope="col">{{'admin.registries.bitstream-formats.table.supportLevel.head' | translate}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let bitstreamFormat of (bitstreamFormats | async)?.payload?.page">
|
||||
<td>{{bitstreamFormat.shortDescription}}</td>
|
||||
<td>{{bitstreamFormat.mimetype}} <span *ngIf="bitstreamFormat.internal">({{'admin.registries.bitstream-formats.formats.table.internal' | translate}})</span></td>
|
||||
<td>{{'admin.registries.bitstream-formats.formats.table.supportLevel.'+bitstreamFormat.supportLevel | translate}}</td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
[checked]="isSelected(bitstreamFormat) | async"
|
||||
(change)="selectBitStreamFormat(bitstreamFormat, $event)"
|
||||
>
|
||||
</label>
|
||||
</td>
|
||||
<td><a [routerLink]="['/admin/registries/bitstream-formats', bitstreamFormat.id, 'edit']">{{bitstreamFormat.shortDescription}}</a></td>
|
||||
<td><a [routerLink]="['/admin/registries/bitstream-formats', bitstreamFormat.id, 'edit']">{{bitstreamFormat.mimetype}} <span *ngIf="bitstreamFormat.internal">({{'admin.registries.bitstream-formats.table.internal' | translate}})</span></a></td>
|
||||
<td><a [routerLink]="['/admin/registries/bitstream-formats', bitstreamFormat.id, 'edit']">{{'admin.registries.bitstream-formats.table.supportLevel.'+bitstreamFormat.supportLevel | translate}}</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</ds-pagination>
|
||||
<div *ngIf="(bitstreamFormats | async)?.payload?.totalElements == 0" class="alert alert-info" role="alert">
|
||||
{{'admin.registries.bitstream-formats.formats.no-items' | translate}}
|
||||
{{'admin.registries.bitstream-formats.no-items' | translate}}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button *ngIf="(bitstreamFormats | async)?.payload?.page?.length > 0" class="btn btn-primary deselect" (click)="deselectAll()">{{'admin.registries.bitstream-formats.table.deselect-all' | translate}}</button>
|
||||
<button *ngIf="(bitstreamFormats | async)?.payload?.page?.length > 0" type="submit" class="btn btn-danger float-right" (click)="deleteFormats()">{{'admin.registries.bitstream-formats.table.delete' | translate}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { BitstreamFormatsComponent } from './bitstream-formats.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { RegistryService } from '../../../core/registry/registry.service';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
@@ -13,86 +12,278 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe';
|
||||
import { HostWindowService } from '../../../shared/host-window.service';
|
||||
import { HostWindowServiceStub } from '../../../shared/testing/host-window-service-stub';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils';
|
||||
import { BitstreamFormatDataService } from '../../../core/data/bitstream-format-data.service';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service-stub';
|
||||
import { BitstreamFormat } from '../../../core/shared/bitstream-format.model';
|
||||
import { BitstreamFormatSupportLevel } from '../../../core/shared/bitstream-format-support-level';
|
||||
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
|
||||
describe('BitstreamFormatsComponent', () => {
|
||||
let comp: BitstreamFormatsComponent;
|
||||
let fixture: ComponentFixture<BitstreamFormatsComponent>;
|
||||
let registryService: RegistryService;
|
||||
const mockFormatsList = [
|
||||
{
|
||||
shortDescription: 'Unknown',
|
||||
description: 'Unknown data format',
|
||||
mimetype: 'application/octet-stream',
|
||||
supportLevel: 0,
|
||||
internal: false,
|
||||
extensions: null
|
||||
},
|
||||
{
|
||||
shortDescription: 'License',
|
||||
description: 'Item-specific license agreed upon to submission',
|
||||
mimetype: 'text/plain; charset=utf-8',
|
||||
supportLevel: 1,
|
||||
internal: true,
|
||||
extensions: null
|
||||
},
|
||||
{
|
||||
shortDescription: 'CC License',
|
||||
description: 'Item-specific Creative Commons license agreed upon to submission',
|
||||
mimetype: 'text/html; charset=utf-8',
|
||||
supportLevel: 2,
|
||||
internal: true,
|
||||
extensions: null
|
||||
},
|
||||
{
|
||||
shortDescription: 'Adobe PDF',
|
||||
description: 'Adobe Portable Document Format',
|
||||
mimetype: 'application/pdf',
|
||||
supportLevel: 0,
|
||||
internal: false,
|
||||
extensions: null
|
||||
}
|
||||
];
|
||||
const mockFormats = createSuccessfulRemoteDataObject$(new PaginatedList(null, mockFormatsList));
|
||||
const registryServiceStub = {
|
||||
getBitstreamFormats: () => mockFormats
|
||||
};
|
||||
let bitstreamFormatService;
|
||||
let scheduler: TestScheduler;
|
||||
let notificationsServiceStub;
|
||||
|
||||
const bitstreamFormat1 = new BitstreamFormat();
|
||||
bitstreamFormat1.uuid = 'test-uuid-1';
|
||||
bitstreamFormat1.id = 'test-uuid-1';
|
||||
bitstreamFormat1.shortDescription = 'Unknown';
|
||||
bitstreamFormat1.description = 'Unknown data format';
|
||||
bitstreamFormat1.mimetype = 'application/octet-stream';
|
||||
bitstreamFormat1.supportLevel = BitstreamFormatSupportLevel.Unknown;
|
||||
bitstreamFormat1.internal = false;
|
||||
bitstreamFormat1.extensions = null;
|
||||
|
||||
const bitstreamFormat2 = new BitstreamFormat();
|
||||
bitstreamFormat2.uuid = 'test-uuid-2';
|
||||
bitstreamFormat2.id = 'test-uuid-2';
|
||||
bitstreamFormat2.shortDescription = 'License';
|
||||
bitstreamFormat2.description = 'Item-specific license agreed upon to submission';
|
||||
bitstreamFormat2.mimetype = 'text/plain; charset=utf-8';
|
||||
bitstreamFormat2.supportLevel = BitstreamFormatSupportLevel.Known;
|
||||
bitstreamFormat2.internal = true;
|
||||
bitstreamFormat2.extensions = null;
|
||||
|
||||
const bitstreamFormat3 = new BitstreamFormat();
|
||||
bitstreamFormat3.uuid = 'test-uuid-3';
|
||||
bitstreamFormat3.id = 'test-uuid-3';
|
||||
bitstreamFormat3.shortDescription = 'CC License';
|
||||
bitstreamFormat3.description = 'Item-specific Creative Commons license agreed upon to submission';
|
||||
bitstreamFormat3.mimetype = 'text/html; charset=utf-8';
|
||||
bitstreamFormat3.supportLevel = BitstreamFormatSupportLevel.Supported;
|
||||
bitstreamFormat3.internal = true;
|
||||
bitstreamFormat3.extensions = null;
|
||||
|
||||
const bitstreamFormat4 = new BitstreamFormat();
|
||||
bitstreamFormat4.uuid = 'test-uuid-4';
|
||||
bitstreamFormat4.id = 'test-uuid-4';
|
||||
bitstreamFormat4.shortDescription = 'Adobe PDF';
|
||||
bitstreamFormat4.description = 'Adobe Portable Document Format';
|
||||
bitstreamFormat4.mimetype = 'application/pdf';
|
||||
bitstreamFormat4.supportLevel = BitstreamFormatSupportLevel.Unknown;
|
||||
bitstreamFormat4.internal = false;
|
||||
bitstreamFormat4.extensions = null;
|
||||
|
||||
const mockFormatsList: BitstreamFormat[] = [
|
||||
bitstreamFormat1,
|
||||
bitstreamFormat2,
|
||||
bitstreamFormat3,
|
||||
bitstreamFormat4
|
||||
];
|
||||
const mockFormatsRD = new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFormatsList));
|
||||
|
||||
const initAsync = () => {
|
||||
notificationsServiceStub = new NotificationsServiceStub();
|
||||
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: observableOf(new RemoteData(false, false, true, undefined, mockFormatsList[0])),
|
||||
getSelectedBitstreamFormats: hot('a', {a: mockFormatsList}),
|
||||
selectBitstreamFormat: {},
|
||||
deselectBitstreamFormat: {},
|
||||
deselectAllBitstreamFormats: {},
|
||||
delete: observableOf(true),
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
providers: [
|
||||
{ provide: RegistryService, useValue: registryServiceStub },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) }
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub}
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
const initBeforeEach = () => {
|
||||
fixture = TestBed.createComponent(BitstreamFormatsComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
registryService = (comp as any).service;
|
||||
};
|
||||
|
||||
describe('Bitstream format page content', () => {
|
||||
beforeEach(async(initAsync));
|
||||
beforeEach(initBeforeEach);
|
||||
|
||||
it('should contain four formats', () => {
|
||||
const tbody: HTMLElement = fixture.debugElement.query(By.css('#formats>tbody')).nativeElement;
|
||||
expect(tbody.children.length).toBe(4);
|
||||
});
|
||||
|
||||
it('should contain the correct formats', () => {
|
||||
const unknownName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(1) td:nth-child(2)')).nativeElement;
|
||||
expect(unknownName.textContent).toBe('Unknown');
|
||||
|
||||
const licenseName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(2) td:nth-child(2)')).nativeElement;
|
||||
expect(licenseName.textContent).toBe('License');
|
||||
|
||||
const ccLicenseName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(3) td:nth-child(2)')).nativeElement;
|
||||
expect(ccLicenseName.textContent).toBe('CC License');
|
||||
|
||||
const adobeName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(4) td:nth-child(2)')).nativeElement;
|
||||
expect(adobeName.textContent).toBe('Adobe PDF');
|
||||
});
|
||||
});
|
||||
|
||||
it('should contain four formats', () => {
|
||||
const tbody: HTMLElement = fixture.debugElement.query(By.css('#formats>tbody')).nativeElement;
|
||||
expect(tbody.children.length).toBe(4);
|
||||
describe('selectBitStreamFormat', () => {
|
||||
beforeEach(async(initAsync));
|
||||
beforeEach(initBeforeEach);
|
||||
it('should select a bitstreamFormat if it was selected in the event', () => {
|
||||
const event = {target: {checked: true}};
|
||||
|
||||
comp.selectBitStreamFormat(bitstreamFormat1, event);
|
||||
|
||||
expect(bitstreamFormatService.selectBitstreamFormat).toHaveBeenCalledWith(bitstreamFormat1);
|
||||
});
|
||||
it('should deselect a bitstreamFormat if it is deselected in the event', () => {
|
||||
const event = {target: {checked: false}};
|
||||
|
||||
comp.selectBitStreamFormat(bitstreamFormat1, event);
|
||||
|
||||
expect(bitstreamFormatService.deselectBitstreamFormat).toHaveBeenCalledWith(bitstreamFormat1);
|
||||
});
|
||||
it('should be called when a user clicks a checkbox', () => {
|
||||
spyOn(comp, 'selectBitStreamFormat');
|
||||
const unknownFormat = fixture.debugElement.query(By.css('#formats tr:nth-child(1) input'));
|
||||
|
||||
const event = {target: {checked: true}};
|
||||
unknownFormat.triggerEventHandler('change', event);
|
||||
|
||||
expect(comp.selectBitStreamFormat).toHaveBeenCalledWith(bitstreamFormat1, event);
|
||||
});
|
||||
});
|
||||
|
||||
it('should contain the correct formats', () => {
|
||||
const unknownName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(1) td:nth-child(1)')).nativeElement;
|
||||
expect(unknownName.textContent).toBe('Unknown');
|
||||
describe('isSelected', () => {
|
||||
beforeEach(async(initAsync));
|
||||
beforeEach(initBeforeEach);
|
||||
it('should return an observable of true if the provided bistream is in the list returned by the service', () => {
|
||||
const result = comp.isSelected(bitstreamFormat1);
|
||||
|
||||
const licenseName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(2) td:nth-child(1)')).nativeElement;
|
||||
expect(licenseName.textContent).toBe('License');
|
||||
expect(result).toBeObservable(cold('b', {b: true}));
|
||||
});
|
||||
it('should return an observable of false if the provided bistream is not in the list returned by the service', () => {
|
||||
const format = new BitstreamFormat();
|
||||
format.uuid = 'new';
|
||||
|
||||
const ccLicenseName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(3) td:nth-child(1)')).nativeElement;
|
||||
expect(ccLicenseName.textContent).toBe('CC License');
|
||||
const result = comp.isSelected(format);
|
||||
|
||||
const adobeName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(4) td:nth-child(1)')).nativeElement;
|
||||
expect(adobeName.textContent).toBe('Adobe PDF');
|
||||
expect(result).toBeObservable(cold('b', {b: false}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('deselectAll', () => {
|
||||
beforeEach(async(initAsync));
|
||||
beforeEach(initBeforeEach);
|
||||
it('should deselect all bitstreamFormats', () => {
|
||||
comp.deselectAll();
|
||||
expect(bitstreamFormatService.deselectAllBitstreamFormats).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should be called when the deselect all button is clicked', () => {
|
||||
spyOn(comp, 'deselectAll');
|
||||
const deselectAllButton = fixture.debugElement.query(By.css('button.deselect'));
|
||||
deselectAllButton.triggerEventHandler('click', null);
|
||||
|
||||
expect(comp.deselectAll).toHaveBeenCalled();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteFormats success', () => {
|
||||
beforeEach(async(() => {
|
||||
notificationsServiceStub = new NotificationsServiceStub();
|
||||
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: observableOf(new RemoteData(false, false, true, undefined, mockFormatsList[0])),
|
||||
getSelectedBitstreamFormats: observableOf(mockFormatsList),
|
||||
selectBitstreamFormat: {},
|
||||
deselectBitstreamFormat: {},
|
||||
deselectAllBitstreamFormats: {},
|
||||
delete: observableOf(true),
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
providers: [
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub}
|
||||
]
|
||||
}).compileComponents();
|
||||
}
|
||||
));
|
||||
|
||||
beforeEach(initBeforeEach);
|
||||
it('should clear bitstream formats ', () => {
|
||||
comp.deleteFormats();
|
||||
|
||||
expect(bitstreamFormatService.clearBitStreamFormatRequests).toHaveBeenCalled();
|
||||
expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat1);
|
||||
expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat2);
|
||||
expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat3);
|
||||
expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat4);
|
||||
|
||||
expect(notificationsServiceStub.success).toHaveBeenCalledWith('admin.registries.bitstream-formats.delete.success.head',
|
||||
'admin.registries.bitstream-formats.delete.success.amount');
|
||||
expect(notificationsServiceStub.error).not.toHaveBeenCalled();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteFormats error', () => {
|
||||
beforeEach(async(() => {
|
||||
notificationsServiceStub = new NotificationsServiceStub();
|
||||
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: observableOf(new RemoteData(false, false, true, undefined, mockFormatsList[0])),
|
||||
getSelectedBitstreamFormats: observableOf(mockFormatsList),
|
||||
selectBitstreamFormat: {},
|
||||
deselectBitstreamFormat: {},
|
||||
deselectAllBitstreamFormats: {},
|
||||
delete: observableOf(false),
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
providers: [
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub}
|
||||
]
|
||||
}).compileComponents();
|
||||
}
|
||||
));
|
||||
|
||||
beforeEach(initBeforeEach);
|
||||
it('should clear bitstream formats ', () => {
|
||||
comp.deleteFormats();
|
||||
|
||||
expect(bitstreamFormatService.clearBitStreamFormatRequests).toHaveBeenCalled();
|
||||
expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat1);
|
||||
expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat2);
|
||||
expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat3);
|
||||
expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat4);
|
||||
|
||||
expect(notificationsServiceStub.error).toHaveBeenCalledWith('admin.registries.bitstream-formats.delete.failure.head',
|
||||
'admin.registries.bitstream-formats.delete.failure.amount');
|
||||
expect(notificationsServiceStub.success).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,10 +1,16 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { RegistryService } from '../../../core/registry/registry.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, zip } from 'rxjs';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { BitstreamFormat } from '../../../core/registry/mock-bitstream-format.model';
|
||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||
import { BitstreamFormat } from '../../../core/shared/bitstream-format.model';
|
||||
import { BitstreamFormatDataService } from '../../../core/data/bitstream-format-data.service';
|
||||
import { FindAllOptions } from '../../../core/data/request.models';
|
||||
import { map, switchMap, take } from 'rxjs/operators';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
/**
|
||||
* This component renders a list of bitstream formats
|
||||
@@ -13,24 +19,125 @@ import { PaginationComponentOptions } from '../../../shared/pagination/paginatio
|
||||
selector: 'ds-bitstream-formats',
|
||||
templateUrl: './bitstream-formats.component.html'
|
||||
})
|
||||
export class BitstreamFormatsComponent {
|
||||
export class BitstreamFormatsComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* A paginated list of bitstream formats to be shown on the page
|
||||
*/
|
||||
bitstreamFormats: Observable<RemoteData<PaginatedList<BitstreamFormat>>>;
|
||||
|
||||
/**
|
||||
* A BehaviourSubject that keeps track of the pageState used to update the currently displayed bitstreamFormats
|
||||
*/
|
||||
pageState: BehaviorSubject<string>;
|
||||
|
||||
/**
|
||||
* The current pagination configuration for the page used by the FindAll method
|
||||
* Currently simply renders all bitstream formats
|
||||
*/
|
||||
config: FindAllOptions = Object.assign(new FindAllOptions(), {
|
||||
elementsPerPage: 20
|
||||
});
|
||||
|
||||
/**
|
||||
* The current pagination configuration for the page
|
||||
* Currently simply renders all bitstream formats
|
||||
*/
|
||||
config: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
|
||||
pageConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
|
||||
id: 'registry-bitstreamformats-pagination',
|
||||
pageSize: 10000
|
||||
pageSize: 20
|
||||
});
|
||||
|
||||
constructor(private registryService: RegistryService) {
|
||||
this.updateFormats();
|
||||
constructor(private notificationsService: NotificationsService,
|
||||
private router: Router,
|
||||
private translateService: TranslateService,
|
||||
private bitstreamFormatService: BitstreamFormatDataService) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the currently selected formats from the registry and updates the presented list
|
||||
*/
|
||||
deleteFormats() {
|
||||
this.bitstreamFormatService.clearBitStreamFormatRequests().subscribe();
|
||||
this.bitstreamFormatService.getSelectedBitstreamFormats().pipe(take(1)).subscribe(
|
||||
(formats) => {
|
||||
const tasks$ = [];
|
||||
for (const format of formats) {
|
||||
if (hasValue(format.id)) {
|
||||
tasks$.push(this.bitstreamFormatService.delete(format));
|
||||
}
|
||||
}
|
||||
zip(...tasks$).subscribe((results: boolean[]) => {
|
||||
const successResponses = results.filter((result: boolean) => result);
|
||||
const failedResponses = results.filter((result: boolean) => !result);
|
||||
if (successResponses.length > 0) {
|
||||
this.showNotification(true, successResponses.length);
|
||||
}
|
||||
if (failedResponses.length > 0) {
|
||||
this.showNotification(false, failedResponses.length);
|
||||
}
|
||||
|
||||
this.deselectAll();
|
||||
|
||||
this.router.navigate([], {
|
||||
queryParams: Object.assign({}, { page: 1 }),
|
||||
queryParamsHandling: 'merge'
|
||||
}); });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deselects all selecetd bitstream formats
|
||||
*/
|
||||
deselectAll() {
|
||||
this.bitstreamFormatService.deselectAllBitstreamFormats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given bitstream format is selected in the list (checkbox)
|
||||
* @param bitstreamFormat
|
||||
*/
|
||||
isSelected(bitstreamFormat: BitstreamFormat): Observable<boolean> {
|
||||
return this.bitstreamFormatService.getSelectedBitstreamFormats().pipe(
|
||||
map((bitstreamFormats: BitstreamFormat[]) => {
|
||||
return bitstreamFormats.find((selectedFormat) => selectedFormat.id === bitstreamFormat.id) != null;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects or deselects a bitstream format based on the checkbox state
|
||||
* @param bitstreamFormat
|
||||
* @param event
|
||||
*/
|
||||
selectBitStreamFormat(bitstreamFormat: BitstreamFormat, event) {
|
||||
event.target.checked ?
|
||||
this.bitstreamFormatService.selectBitstreamFormat(bitstreamFormat) :
|
||||
this.bitstreamFormatService.deselectBitstreamFormat(bitstreamFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show notifications for an amount of deleted bitstream formats
|
||||
* @param success Whether or not the notification should be a success message (error message when false)
|
||||
* @param amount The amount of deleted bitstream formats
|
||||
*/
|
||||
private showNotification(success: boolean, amount: number) {
|
||||
const prefix = 'admin.registries.bitstream-formats.delete';
|
||||
const suffix = success ? 'success' : 'failure';
|
||||
|
||||
const messages = observableCombineLatest(
|
||||
this.translateService.get(`${prefix}.${suffix}.head`),
|
||||
this.translateService.get(`${prefix}.${suffix}.amount`, {amount: amount})
|
||||
);
|
||||
messages.subscribe(([head, content]) => {
|
||||
|
||||
if (success) {
|
||||
this.notificationsService.success(head, content);
|
||||
} else {
|
||||
this.notificationsService.error(head, content);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,14 +145,26 @@ export class BitstreamFormatsComponent {
|
||||
* @param event The page change event
|
||||
*/
|
||||
onPageChange(event) {
|
||||
this.config.currentPage = event;
|
||||
this.updateFormats();
|
||||
this.config = Object.assign(new FindAllOptions(), this.config, {
|
||||
currentPage: event,
|
||||
});
|
||||
this.pageConfig.currentPage = event;
|
||||
this.pageState.next('pageChange');
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.pageState = new BehaviorSubject('init');
|
||||
this.bitstreamFormats = this.pageState.pipe(
|
||||
switchMap(() => {
|
||||
return this.updateFormats()
|
||||
;
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to update the bitstream formats that are shown
|
||||
* Finds all formats based on the current config
|
||||
*/
|
||||
private updateFormats() {
|
||||
this.bitstreamFormats = this.registryService.getBitstreamFormats(this.config);
|
||||
return this.bitstreamFormatService.findAll(this.config);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,30 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { BitstreamFormatsComponent } from './bitstream-formats.component';
|
||||
import { SharedModule } from '../../../shared/shared.module';
|
||||
import { FormatFormComponent } from './format-form/format-form.component';
|
||||
import { EditBitstreamFormatComponent } from './edit-bitstream-format/edit-bitstream-format.component';
|
||||
import { BitstreamFormatsRoutingModule } from './bitstream-formats-routing.module';
|
||||
import { AddBitstreamFormatComponent } from './add-bitstream-format/add-bitstream-format.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
SharedModule,
|
||||
RouterModule,
|
||||
TranslateModule,
|
||||
BitstreamFormatsRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
BitstreamFormatsComponent,
|
||||
EditBitstreamFormatComponent,
|
||||
AddBitstreamFormatComponent,
|
||||
FormatFormComponent
|
||||
],
|
||||
entryComponents: []
|
||||
})
|
||||
export class BitstreamFormatsModule {
|
||||
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { find } from 'rxjs/operators';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { BitstreamFormat } from '../../../core/shared/bitstream-format.model';
|
||||
import { BitstreamFormatDataService } from '../../../core/data/bitstream-format-data.service';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
|
||||
/**
|
||||
* This class represents a resolver that requests a specific bitstreamFormat before the route is activated
|
||||
*/
|
||||
@Injectable()
|
||||
export class BitstreamFormatsResolver implements Resolve<RemoteData<BitstreamFormat>> {
|
||||
constructor(private bitstreamFormatDataService: BitstreamFormatDataService) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for resolving an bitstreamFormat based on the parameters in the current route
|
||||
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
|
||||
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
|
||||
* @returns Observable<<RemoteData<BitstreamFormat>> Emits the found bitstreamFormat based on the parameters in the current route,
|
||||
* or an error if something went wrong
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<BitstreamFormat>> {
|
||||
return this.bitstreamFormatDataService.findById(route.params.id)
|
||||
.pipe(
|
||||
find((RD) => hasValue(RD.error) || RD.hasSucceeded),
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-4">
|
||||
<h2 id="sub-header"
|
||||
class="border-bottom mb-2">{{'admin.registries.bitstream-formats.edit.head' | translate:{format: (bitstreamFormatRD$ | async)?.payload.shortDescription} }}</h2>
|
||||
|
||||
<ds-bitstream-format-form [bitstreamFormat]="(bitstreamFormatRD$ | async)?.payload" (updatedFormat)="updateFormat($event)"></ds-bitstream-format-form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,123 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { RouterStub } from '../../../../shared/testing/router-stub';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { EditBitstreamFormatComponent } from './edit-bitstream-format.component';
|
||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../../shared/testing/notifications-service-stub';
|
||||
import { BitstreamFormatDataService } from '../../../../core/data/bitstream-format-data.service';
|
||||
import { RestResponse } from '../../../../core/cache/response.models';
|
||||
import { BitstreamFormat } from '../../../../core/shared/bitstream-format.model';
|
||||
import { BitstreamFormatSupportLevel } from '../../../../core/shared/bitstream-format-support-level';
|
||||
import { ResourceType } from '../../../../core/shared/resource-type';
|
||||
|
||||
describe('EditBitstreamFormatComponent', () => {
|
||||
let comp: EditBitstreamFormatComponent;
|
||||
let fixture: ComponentFixture<EditBitstreamFormatComponent>;
|
||||
|
||||
const bitstreamFormat = new BitstreamFormat();
|
||||
bitstreamFormat.uuid = 'test-uuid-1';
|
||||
bitstreamFormat.id = 'test-uuid-1';
|
||||
bitstreamFormat.shortDescription = 'Unknown';
|
||||
bitstreamFormat.description = 'Unknown data format';
|
||||
bitstreamFormat.mimetype = 'application/octet-stream';
|
||||
bitstreamFormat.supportLevel = BitstreamFormatSupportLevel.Unknown;
|
||||
bitstreamFormat.internal = false;
|
||||
bitstreamFormat.extensions = null;
|
||||
|
||||
const routeStub = {
|
||||
data: observableOf({
|
||||
bitstreamFormat: new RemoteData(false, false, true, null, bitstreamFormat)
|
||||
})
|
||||
};
|
||||
|
||||
let router;
|
||||
let notificationService: NotificationsServiceStub;
|
||||
let bitstreamFormatDataService: BitstreamFormatDataService;
|
||||
|
||||
const initAsync = () => {
|
||||
router = new RouterStub();
|
||||
notificationService = new NotificationsServiceStub();
|
||||
bitstreamFormatDataService = jasmine.createSpyObj('bitstreamFormatDataService', {
|
||||
updateBitstreamFormat: observableOf(new RestResponse(true, 200, 'Success'))
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [EditBitstreamFormatComponent],
|
||||
providers: [
|
||||
{provide: ActivatedRoute, useValue: routeStub},
|
||||
{provide: Router, useValue: router},
|
||||
{provide: NotificationsService, useValue: notificationService},
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatDataService},
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
}).compileComponents();
|
||||
};
|
||||
|
||||
const initBeforeEach = () => {
|
||||
fixture = TestBed.createComponent(EditBitstreamFormatComponent);
|
||||
comp = fixture.componentInstance;
|
||||
|
||||
fixture.detectChanges();
|
||||
};
|
||||
|
||||
describe('init', () => {
|
||||
beforeEach(async(initAsync));
|
||||
beforeEach(initBeforeEach);
|
||||
it('should initialise the bitstreamFormat based on the route', () => {
|
||||
|
||||
comp.bitstreamFormatRD$.subscribe((format: RemoteData<BitstreamFormat>) => {
|
||||
expect(format).toEqual(new RemoteData(false, false, true, null, bitstreamFormat));
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('updateFormat success', () => {
|
||||
beforeEach(async(initAsync));
|
||||
beforeEach(initBeforeEach);
|
||||
it('should send the updated form to the service, show a notification and navigate to ', () => {
|
||||
comp.updateFormat(bitstreamFormat);
|
||||
|
||||
expect(bitstreamFormatDataService.updateBitstreamFormat).toHaveBeenCalledWith(bitstreamFormat);
|
||||
expect(notificationService.success).toHaveBeenCalled();
|
||||
expect(router.navigate).toHaveBeenCalledWith(['/admin/registries/bitstream-formats']);
|
||||
|
||||
});
|
||||
});
|
||||
describe('updateFormat error', () => {
|
||||
beforeEach(async( () => {
|
||||
router = new RouterStub();
|
||||
notificationService = new NotificationsServiceStub();
|
||||
bitstreamFormatDataService = jasmine.createSpyObj('bitstreamFormatDataService', {
|
||||
updateBitstreamFormat: observableOf(new RestResponse(false, 400, 'Bad Request'))
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [EditBitstreamFormatComponent],
|
||||
providers: [
|
||||
{provide: ActivatedRoute, useValue: routeStub},
|
||||
{provide: Router, useValue: router},
|
||||
{provide: NotificationsService, useValue: notificationService},
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatDataService},
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
}).compileComponents();
|
||||
}));
|
||||
beforeEach(initBeforeEach);
|
||||
it('should send the updated form to the service, show a notification and navigate to ', () => {
|
||||
comp.updateFormat(bitstreamFormat);
|
||||
|
||||
expect(bitstreamFormatDataService.updateBitstreamFormat).toHaveBeenCalledWith(bitstreamFormat);
|
||||
expect(notificationService.error).toHaveBeenCalled();
|
||||
expect(router.navigate).not.toHaveBeenCalled();
|
||||
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,62 @@
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { BitstreamFormat } from '../../../../core/shared/bitstream-format.model';
|
||||
import { BitstreamFormatDataService } from '../../../../core/data/bitstream-format-data.service';
|
||||
import { RestResponse } from '../../../../core/cache/response.models';
|
||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||
import { getBitstreamFormatsModulePath } from '../../admin-registries-routing.module';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
/**
|
||||
* This component renders the edit page of a bitstream format.
|
||||
* The route parameter 'id' is used to request the bitstream format.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ds-edit-bitstream-format',
|
||||
templateUrl: './edit-bitstream-format.component.html',
|
||||
})
|
||||
export class EditBitstreamFormatComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* The bitstream format wrapped in a remote-data object
|
||||
*/
|
||||
bitstreamFormatRD$: Observable<RemoteData<BitstreamFormat>>;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private notificationService: NotificationsService,
|
||||
private translateService: TranslateService,
|
||||
private bitstreamFormatDataService: BitstreamFormatDataService,
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bitstreamFormatRD$ = this.route.data.pipe(
|
||||
map((data) => data.bitstreamFormat as RemoteData<BitstreamFormat>)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the bitstream format based on the provided bitstream format emitted by the form.
|
||||
* When successful, a success notification will be shown and the user will be navigated back to the overview page.
|
||||
* When failed, an error notification will be shown.
|
||||
*/
|
||||
updateFormat(bitstreamFormat: BitstreamFormat) {
|
||||
this.bitstreamFormatDataService.updateBitstreamFormat(bitstreamFormat).pipe(take(1)
|
||||
).subscribe((response: RestResponse) => {
|
||||
if (response.isSuccessful) {
|
||||
this.notificationService.success(this.translateService.get('admin.registries.bitstream-formats.edit.success.head'),
|
||||
this.translateService.get('admin.registries.bitstream-formats.edit.success.content'));
|
||||
this.router.navigate([getBitstreamFormatsModulePath()]);
|
||||
} else {
|
||||
this.notificationService.error('admin.registries.bitstream-formats.edit.failure.head',
|
||||
'admin.registries.bitstream-formats.create.edit.content');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
<ds-form *ngIf="formModel"
|
||||
[formId]="'comcol-form-id'"
|
||||
[formModel]="formModel" (submitForm)="onSubmit()" (cancel)="onCancel()"></ds-form>
|
@@ -0,0 +1,104 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { RouterStub } from '../../../../shared/testing/router-stub';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
import { FormatFormComponent } from './format-form.component';
|
||||
import { BitstreamFormat } from '../../../../core/shared/bitstream-format.model';
|
||||
import { BitstreamFormatSupportLevel } from '../../../../core/shared/bitstream-format-support-level';
|
||||
import { DynamicCheckboxModel, DynamicFormArrayModel, DynamicInputModel } from '@ng-dynamic-forms/core';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { isEmpty } from '../../../../shared/empty.util';
|
||||
|
||||
describe('FormatFormComponent', () => {
|
||||
let comp: FormatFormComponent;
|
||||
let fixture: ComponentFixture<FormatFormComponent>;
|
||||
|
||||
const router = new RouterStub();
|
||||
|
||||
const bitstreamFormat = new BitstreamFormat();
|
||||
bitstreamFormat.uuid = 'test-uuid-1';
|
||||
bitstreamFormat.id = 'test-uuid-1';
|
||||
bitstreamFormat.shortDescription = 'Unknown';
|
||||
bitstreamFormat.description = 'Unknown data format';
|
||||
bitstreamFormat.mimetype = 'application/octet-stream';
|
||||
bitstreamFormat.supportLevel = BitstreamFormatSupportLevel.Unknown;
|
||||
bitstreamFormat.internal = false;
|
||||
bitstreamFormat.extensions = [];
|
||||
|
||||
const submittedBitstreamFormat = new BitstreamFormat();
|
||||
submittedBitstreamFormat.id = bitstreamFormat.id;
|
||||
submittedBitstreamFormat.shortDescription = bitstreamFormat.shortDescription;
|
||||
submittedBitstreamFormat.mimetype = bitstreamFormat.mimetype;
|
||||
submittedBitstreamFormat.description = bitstreamFormat.description;
|
||||
submittedBitstreamFormat.supportLevel = bitstreamFormat.supportLevel;
|
||||
submittedBitstreamFormat.internal = bitstreamFormat.internal;
|
||||
submittedBitstreamFormat.extensions = bitstreamFormat.extensions;
|
||||
|
||||
const initAsync = () => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), ReactiveFormsModule, FormsModule, TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [FormatFormComponent],
|
||||
providers: [
|
||||
{provide: Router, useValue: router},
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
}).compileComponents();
|
||||
};
|
||||
|
||||
const initBeforeEach = () => {
|
||||
fixture = TestBed.createComponent(FormatFormComponent);
|
||||
comp = fixture.componentInstance;
|
||||
|
||||
comp.bitstreamFormat = bitstreamFormat;
|
||||
fixture.detectChanges();
|
||||
};
|
||||
|
||||
describe('initialise', () => {
|
||||
beforeEach(async(initAsync));
|
||||
beforeEach(initBeforeEach);
|
||||
it('should initialises the values in the form', () => {
|
||||
|
||||
expect((comp.formModel[0] as DynamicInputModel).value).toBe(bitstreamFormat.shortDescription);
|
||||
expect((comp.formModel[1] as DynamicInputModel).value).toBe(bitstreamFormat.mimetype);
|
||||
expect((comp.formModel[2] as DynamicInputModel).value).toBe(bitstreamFormat.description);
|
||||
expect((comp.formModel[3] as DynamicInputModel).value).toBe(bitstreamFormat.supportLevel);
|
||||
expect((comp.formModel[4] as DynamicCheckboxModel).value).toBe(bitstreamFormat.internal);
|
||||
|
||||
const formArray = (comp.formModel[5] as DynamicFormArrayModel);
|
||||
const extensions = [];
|
||||
for (let i = 0; i < formArray.groups.length; i++) {
|
||||
const value = (formArray.get(i).get(0) as DynamicInputModel).value;
|
||||
if (!isEmpty(value)) {
|
||||
extensions.push((formArray.get(i).get(0) as DynamicInputModel).value);
|
||||
}
|
||||
}
|
||||
|
||||
expect(extensions).toEqual(bitstreamFormat.extensions);
|
||||
|
||||
});
|
||||
});
|
||||
describe('onSubmit', () => {
|
||||
beforeEach(async(initAsync));
|
||||
beforeEach(initBeforeEach);
|
||||
|
||||
it('should emit the bitstreamFormat currently present in the form', () => {
|
||||
spyOn(comp.updatedFormat, 'emit');
|
||||
comp.onSubmit();
|
||||
|
||||
expect(comp.updatedFormat.emit).toHaveBeenCalledWith(submittedBitstreamFormat);
|
||||
});
|
||||
});
|
||||
describe('onCancel', () => {
|
||||
beforeEach(async(initAsync));
|
||||
beforeEach(initBeforeEach);
|
||||
|
||||
it('should navigate back to the bitstream overview', () => {
|
||||
comp.onCancel();
|
||||
expect(router.navigate).toHaveBeenCalledWith(['/admin/registries/bitstream-formats']);
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,194 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { BitstreamFormat } from '../../../../core/shared/bitstream-format.model';
|
||||
import { BitstreamFormatSupportLevel } from '../../../../core/shared/bitstream-format-support-level';
|
||||
import {
|
||||
DynamicCheckboxModel,
|
||||
DynamicFormArrayModel,
|
||||
DynamicFormControlLayout, DynamicFormControlLayoutConfig,
|
||||
DynamicFormControlModel,
|
||||
DynamicFormService,
|
||||
DynamicInputModel,
|
||||
DynamicSelectModel,
|
||||
DynamicTextAreaModel
|
||||
} from '@ng-dynamic-forms/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { getBitstreamFormatsModulePath } from '../../admin-registries-routing.module';
|
||||
import { hasValue, isEmpty } from '../../../../shared/empty.util';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
/**
|
||||
* The component responsible for rendering the form to create/edit a bitstream format
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ds-bitstream-format-form',
|
||||
templateUrl: './format-form.component.html'
|
||||
})
|
||||
export class FormatFormComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* The current bitstream format
|
||||
* This can either be and existing one or a new one
|
||||
*/
|
||||
@Input() bitstreamFormat: BitstreamFormat = new BitstreamFormat();
|
||||
|
||||
/**
|
||||
* EventEmitter that will emit the updated bitstream format
|
||||
*/
|
||||
@Output() updatedFormat: EventEmitter<BitstreamFormat> = new EventEmitter<BitstreamFormat>();
|
||||
|
||||
/**
|
||||
* The different supported support level of the bitstream format
|
||||
*/
|
||||
supportLevelOptions = [{label: BitstreamFormatSupportLevel.Known, value: BitstreamFormatSupportLevel.Known},
|
||||
{label: BitstreamFormatSupportLevel.Unknown, value: BitstreamFormatSupportLevel.Unknown},
|
||||
{label: BitstreamFormatSupportLevel.Supported, value: BitstreamFormatSupportLevel.Supported}];
|
||||
|
||||
/**
|
||||
* Styling element for repeatable field
|
||||
*/
|
||||
arrayElementLayout: DynamicFormControlLayout = {
|
||||
grid: {
|
||||
group: 'form-row',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Styling element for element of repeatable field
|
||||
*/
|
||||
arrayInputElementLayout: DynamicFormControlLayout = {
|
||||
grid: {
|
||||
host: 'col'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The form model representing the bitstream format
|
||||
*/
|
||||
formModel: DynamicFormControlModel[] = [
|
||||
new DynamicInputModel({
|
||||
id: 'shortDescription',
|
||||
name: 'shortDescription',
|
||||
label: 'admin.registries.bitstream-formats.edit.shortDescription.label',
|
||||
hint: 'admin.registries.bitstream-formats.edit.shortDescription.hint',
|
||||
required: true,
|
||||
validators: {
|
||||
required: null
|
||||
},
|
||||
errorMessages: {
|
||||
required: 'Please enter a name for this bitstream format'
|
||||
},
|
||||
}),
|
||||
new DynamicInputModel({
|
||||
id: 'mimetype',
|
||||
name: 'mimetype',
|
||||
label: 'admin.registries.bitstream-formats.edit.mimetype.label',
|
||||
hint: 'admin.registries.bitstream-formats.edit.mimetype.hint',
|
||||
|
||||
}),
|
||||
new DynamicTextAreaModel({
|
||||
id: 'description',
|
||||
name: 'description',
|
||||
label: 'admin.registries.bitstream-formats.edit.description.label',
|
||||
hint: 'admin.registries.bitstream-formats.edit.description.hint',
|
||||
|
||||
}),
|
||||
new DynamicSelectModel({
|
||||
id: 'supportLevel',
|
||||
name: 'supportLevel',
|
||||
options: this.supportLevelOptions,
|
||||
label: 'admin.registries.bitstream-formats.edit.supportLevel.label',
|
||||
hint: 'admin.registries.bitstream-formats.edit.supportLevel.hint',
|
||||
value: this.supportLevelOptions[0].value
|
||||
|
||||
}),
|
||||
new DynamicCheckboxModel({
|
||||
id: 'internal',
|
||||
name: 'internal',
|
||||
label: 'Internal',
|
||||
hint: 'admin.registries.bitstream-formats.edit.internal.hint',
|
||||
}),
|
||||
new DynamicFormArrayModel({
|
||||
id: 'extensions',
|
||||
name: 'extensions',
|
||||
label: 'admin.registries.bitstream-formats.edit.extensions.label',
|
||||
groupFactory: () => [
|
||||
new DynamicInputModel({
|
||||
id: 'extension',
|
||||
placeholder: 'admin.registries.bitstream-formats.edit.extensions.placeholder',
|
||||
}, this.arrayInputElementLayout)
|
||||
]
|
||||
}, this.arrayElementLayout),
|
||||
];
|
||||
|
||||
constructor(private dynamicFormService: DynamicFormService,
|
||||
private translateService: TranslateService,
|
||||
private router: Router) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
this.initValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the form based on the provided bitstream format
|
||||
*/
|
||||
initValues() {
|
||||
this.formModel.forEach(
|
||||
(fieldModel: DynamicFormControlModel) => {
|
||||
if (fieldModel.name === 'extensions') {
|
||||
if (hasValue(this.bitstreamFormat.extensions)) {
|
||||
const extenstions = this.bitstreamFormat.extensions;
|
||||
const formArray = (fieldModel as DynamicFormArrayModel);
|
||||
for (let i = 0; i < extenstions.length; i++) {
|
||||
formArray.insertGroup(i).group[0] = new DynamicInputModel({
|
||||
id: `extension-${i}`,
|
||||
value: extenstions[i]
|
||||
}, this.arrayInputElementLayout);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (hasValue(this.bitstreamFormat[fieldModel.name])) {
|
||||
(fieldModel as DynamicInputModel).value = this.bitstreamFormat[fieldModel.name];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an updated bistream format based on the current values in the form
|
||||
* Emits the updated bitstream format trouhg the updatedFormat emitter
|
||||
*/
|
||||
onSubmit() {
|
||||
const updatedBitstreamFormat = Object.assign(new BitstreamFormat(),
|
||||
{
|
||||
id: this.bitstreamFormat.id
|
||||
});
|
||||
|
||||
this.formModel.forEach(
|
||||
(fieldModel: DynamicFormControlModel) => {
|
||||
if (fieldModel.name === 'extensions') {
|
||||
const formArray = (fieldModel as DynamicFormArrayModel);
|
||||
const extensions = [];
|
||||
for (let i = 0; i < formArray.groups.length; i++) {
|
||||
const value = (formArray.get(i).get(0) as DynamicInputModel).value;
|
||||
if (!isEmpty(value)) {
|
||||
extensions.push((formArray.get(i).get(0) as DynamicInputModel).value);
|
||||
}
|
||||
}
|
||||
updatedBitstreamFormat.extensions = extensions;
|
||||
} else {
|
||||
updatedBitstreamFormat[fieldModel.name] = (fieldModel as DynamicInputModel).value;
|
||||
}
|
||||
});
|
||||
this.updatedFormat.emit(updatedBitstreamFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the edit/create action of the bitstream format and navigates back to the bitstream format registry
|
||||
*/
|
||||
onCancel() {
|
||||
this.router.navigate([getBitstreamFormatsModulePath()]);
|
||||
}
|
||||
}
|
@@ -1,11 +1,19 @@
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { URLCombiner } from '../core/url-combiner/url-combiner';
|
||||
import { getAdminModulePath } from '../app-routing.module';
|
||||
|
||||
const REGISTRIES_MODULE_PATH = 'registries';
|
||||
|
||||
export function getRegistriesModulePath() {
|
||||
return new URLCombiner(getAdminModulePath(), REGISTRIES_MODULE_PATH).toString();
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild([
|
||||
{
|
||||
path: 'registries',
|
||||
path: REGISTRIES_MODULE_PATH,
|
||||
loadChildren: './admin-registries/admin-registries.module#AdminRegistriesModule'
|
||||
}
|
||||
])
|
||||
|
@@ -19,6 +19,7 @@ import { ENV_CONFIG, GLOBAL_CONFIG } from '../../../config';
|
||||
import { BrowseEntrySearchOptions } from '../../core/browse/browse-entry-search-options.model';
|
||||
import { toRemoteData } from '../+browse-by-metadata-page/browse-by-metadata-page.component.spec';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
import { VarDirective } from '../../shared/utils/var.directive';
|
||||
|
||||
describe('BrowseByDatePageComponent', () => {
|
||||
let comp: BrowseByDatePageComponent;
|
||||
@@ -69,7 +70,7 @@ describe('BrowseByDatePageComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [BrowseByDatePageComponent, EnumKeysPipe],
|
||||
declarations: [BrowseByDatePageComponent, EnumKeysPipe, VarDirective],
|
||||
providers: [
|
||||
{ provide: GLOBAL_CONFIG, useValue: ENV_CONFIG },
|
||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||
|
@@ -1,7 +1,31 @@
|
||||
<div class="container">
|
||||
<div class="browse-by-metadata w-100">
|
||||
<ng-container *ngVar="(parent$ | async) as parent">
|
||||
<ng-container *ngIf="parent?.payload as parentContext">
|
||||
<header class="comcol-header border-bottom mb-4 pb-4">
|
||||
<!-- Parent Name -->
|
||||
<ds-comcol-page-header [name]="parentContext.name">
|
||||
</ds-comcol-page-header>
|
||||
<!-- Handle -->
|
||||
<ds-comcol-page-handle
|
||||
[content]="parentContext.handle"
|
||||
[title]="parentContext.type+'.page.handle'" >
|
||||
</ds-comcol-page-handle>
|
||||
<!-- Introductory text -->
|
||||
<ds-comcol-page-content [content]="parentContext.introductoryText" [hasInnerHtml]="true">
|
||||
</ds-comcol-page-content>
|
||||
<!-- News -->
|
||||
<ds-comcol-page-content [content]="parentContext.sidebarText" [hasInnerHtml]="true" [title]="'community.page.news'">
|
||||
</ds-comcol-page-content>
|
||||
</header>
|
||||
<!-- Browse-By Links -->
|
||||
<ds-comcol-page-browse-by [id]="parentContext.id" [contentType]="parentContext.type"></ds-comcol-page-browse-by>
|
||||
</ng-container></ng-container>
|
||||
|
||||
<section class="comcol-page-browse-section">
|
||||
<div class="browse-by-metadata w-100">
|
||||
<ds-browse-by *ngIf="startsWithOptions" class="col-xs-12 w-100"
|
||||
title="{{'browse.title' | translate:{collection: (parent$ | async)?.payload?.name || '', field: 'browse.metadata.' + browseId | translate, value: (value)? '"' + value + '"': ''} }}"
|
||||
parentname="{{(parent$ | async)?.payload?.name || ''}}"
|
||||
[objects$]="(items$ !== undefined)? items$ : browseEntries$"
|
||||
[paginationConfig]="paginationConfig"
|
||||
[sortConfig]="sortConfig"
|
||||
@@ -15,4 +39,17 @@
|
||||
</ds-browse-by>
|
||||
<ds-loading *ngIf="!startsWithOptions" message="{{'loading.browse-by-page' | translate}}"></ds-loading>
|
||||
</div>
|
||||
</section>
|
||||
<ng-container *ngVar="(parent$ | async) as parent">
|
||||
<ng-container *ngIf="parent?.payload as parentContext">
|
||||
<footer *ngIf="parentContext.copyrightText" class="border-top my-5 pt-4">
|
||||
<div >
|
||||
|
||||
<!-- Copyright -->
|
||||
<ds-comcol-page-content [content]="parentContext.copyrightText" [hasInnerHtml]="true">
|
||||
</ds-comcol-page-content>
|
||||
</div>
|
||||
</footer>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
@@ -23,6 +23,7 @@ import { MockRouter } from '../../shared/mocks/mock-router';
|
||||
import { ResourceType } from '../../core/shared/resource-type';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
import { BrowseEntry } from '../../core/shared/browse-entry.model';
|
||||
import { VarDirective } from '../../shared/utils/var.directive';
|
||||
|
||||
describe('BrowseByMetadataPageComponent', () => {
|
||||
let comp: BrowseByMetadataPageComponent;
|
||||
@@ -86,7 +87,7 @@ describe('BrowseByMetadataPageComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [BrowseByMetadataPageComponent, EnumKeysPipe],
|
||||
declarations: [BrowseByMetadataPageComponent, EnumKeysPipe, VarDirective],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||
{ provide: BrowseService, useValue: mockBrowseService },
|
||||
|
@@ -18,6 +18,7 @@ import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.serv
|
||||
import { BrowseService } from '../../core/browse/browse.service';
|
||||
import { MockRouter } from '../../shared/mocks/mock-router';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
import { VarDirective } from '../../shared/utils/var.directive';
|
||||
|
||||
describe('BrowseByTitlePageComponent', () => {
|
||||
let comp: BrowseByTitlePageComponent;
|
||||
@@ -64,7 +65,7 @@ describe('BrowseByTitlePageComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [BrowseByTitlePageComponent, EnumKeysPipe],
|
||||
declarations: [BrowseByTitlePageComponent, EnumKeysPipe, VarDirective],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||
{ provide: BrowseService, useValue: mockBrowseService },
|
||||
|
@@ -0,0 +1,57 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h2>{{'collection.edit.item-mapper.head' | translate}}</h2>
|
||||
<p [innerHTML]="'collection.edit.item-mapper.collection' | translate:{ name: (collectionRD$ | async)?.payload?.name }" id="collection-name"></p>
|
||||
<p>{{'collection.edit.item-mapper.description' | translate}}</p>
|
||||
|
||||
<ngb-tabset (tabChange)="tabChange($event)" [destroyOnHide]="true" #tabs="ngbTabset">
|
||||
<ngb-tab title="{{'collection.edit.item-mapper.tabs.browse' | translate}}" id="browseTab">
|
||||
<ng-template ngbTabContent>
|
||||
<div class="mt-2">
|
||||
<ds-item-select class="mt-2"
|
||||
[key]="'browse'"
|
||||
[dsoRD$]="collectionItemsRD$"
|
||||
[paginationOptions]="(searchOptions$ | async)?.pagination"
|
||||
[confirmButton]="'collection.edit.item-mapper.remove'"
|
||||
[cancelButton]="'collection.edit.item-mapper.cancel'"
|
||||
[dangerConfirm]="true"
|
||||
[hideCollection]="true"
|
||||
(confirm)="mapItems($event, true)"
|
||||
(cancel)="onCancel()"></ds-item-select>
|
||||
</div>
|
||||
</ng-template>
|
||||
</ngb-tab>
|
||||
<ngb-tab title="{{'collection.edit.item-mapper.tabs.map' | translate}}" id="mapTab">
|
||||
<ng-template ngbTabContent>
|
||||
<div class="row mt-2">
|
||||
<div class="col-12 col-lg-6">
|
||||
<ds-search-form id="search-form"
|
||||
[query]="(searchOptions$ | async)?.query"
|
||||
[scope]="(searchOptions$ | async)?.scope"
|
||||
[currentUrl]="'./'"
|
||||
[inPlaceSearch]="true"
|
||||
(submitSearch)="performedSearch = true">
|
||||
</ds-search-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="performedSearch">
|
||||
<ds-item-select class="mt-2"
|
||||
[key]="'map'"
|
||||
[dsoRD$]="mappedItemsRD$"
|
||||
[paginationOptions]="(searchOptions$ | async)?.pagination"
|
||||
[confirmButton]="'collection.edit.item-mapper.confirm'"
|
||||
[cancelButton]="'collection.edit.item-mapper.cancel'"
|
||||
(confirm)="mapItems($event)"
|
||||
(cancel)="onCancel()"></ds-item-select>
|
||||
</div>
|
||||
<div *ngIf="!performedSearch" class="alert alert-info w-100" role="alert">
|
||||
{{'collection.edit.item-mapper.no-search' | translate}}
|
||||
</div>
|
||||
</ng-template>
|
||||
</ngb-tab>
|
||||
</ngb-tabset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1 @@
|
||||
@import '../../../styles/variables.scss';
|
@@ -0,0 +1,214 @@
|
||||
import { CollectionItemMapperComponent } from './collection-item-mapper.component';
|
||||
import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import { SearchFormComponent } from '../../shared/search-form/search-form.component';
|
||||
import { SearchPageModule } from '../../+search-page/search-page.module';
|
||||
import { ObjectCollectionComponent } from '../../shared/object-collection/object-collection.component';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ActivatedRouteStub } from '../../shared/testing/active-router-stub';
|
||||
import { RouterStub } from '../../shared/testing/router-stub';
|
||||
import { SearchConfigurationService } from '../../+search-page/search-service/search-configuration.service';
|
||||
import { SearchService } from '../../+search-page/search-service/search.service';
|
||||
import { SearchServiceStub } from '../../shared/testing/search-service-stub';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub';
|
||||
import { ItemDataService } from '../../core/data/item-data.service';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { SharedModule } from '../../shared/shared.module';
|
||||
import { Collection } from '../../core/shared/collection.model';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { PaginatedSearchOptions } from '../../+search-page/paginated-search-options.model';
|
||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { EventEmitter, NgModule } from '@angular/core';
|
||||
import { HostWindowService } from '../../shared/host-window.service';
|
||||
import { HostWindowServiceStub } from '../../shared/testing/host-window-service-stub';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { PaginatedList } from '../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../core/shared/page-info.model';
|
||||
import { CollectionDataService } from '../../core/data/collection-data.service';
|
||||
import { PaginationComponent } from '../../shared/pagination/pagination.component';
|
||||
import { EnumKeysPipe } from '../../shared/utils/enum-keys-pipe';
|
||||
import { ItemSelectComponent } from '../../shared/object-select/item-select/item-select.component';
|
||||
import { ObjectSelectService } from '../../shared/object-select/object-select.service';
|
||||
import { ObjectSelectServiceStub } from '../../shared/testing/object-select-service-stub';
|
||||
import { VarDirective } from '../../shared/utils/var.directive';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { of as observableOf, of } from 'rxjs/internal/observable/of';
|
||||
import { RestResponse } from '../../core/cache/response.models';
|
||||
import { SearchFixedFilterService } from '../../+search-page/search-filters/search-filter/search-fixed-filter.service';
|
||||
import { RouteService } from '../../core/services/route.service';
|
||||
import { ErrorComponent } from '../../shared/error/error.component';
|
||||
import { LoadingComponent } from '../../shared/loading/loading.component';
|
||||
|
||||
describe('CollectionItemMapperComponent', () => {
|
||||
let comp: CollectionItemMapperComponent;
|
||||
let fixture: ComponentFixture<CollectionItemMapperComponent>;
|
||||
|
||||
let route: ActivatedRoute;
|
||||
let router: Router;
|
||||
let searchConfigService: SearchConfigurationService;
|
||||
let searchService: SearchService;
|
||||
let notificationsService: NotificationsService;
|
||||
let itemDataService: ItemDataService;
|
||||
|
||||
const mockCollection: Collection = Object.assign(new Collection(), {
|
||||
id: 'ce41d451-97ed-4a9c-94a1-7de34f16a9f4',
|
||||
name: 'test-collection'
|
||||
});
|
||||
const mockCollectionRD: RemoteData<Collection> = new RemoteData<Collection>(false, false, true, null, mockCollection);
|
||||
const mockSearchOptions = of(new PaginatedSearchOptions({
|
||||
pagination: Object.assign(new PaginationComponentOptions(), {
|
||||
id: 'search-page-configuration',
|
||||
pageSize: 10,
|
||||
currentPage: 1
|
||||
}),
|
||||
sort: new SortOptions('dc.title', SortDirection.ASC),
|
||||
scope: mockCollection.id
|
||||
}));
|
||||
const url = 'http://test.url';
|
||||
const urlWithParam = url + '?param=value';
|
||||
const routerStub = Object.assign(new RouterStub(), {
|
||||
url: urlWithParam,
|
||||
navigateByUrl: {},
|
||||
navigate: {}
|
||||
});
|
||||
const searchConfigServiceStub = {
|
||||
paginatedSearchOptions: mockSearchOptions
|
||||
};
|
||||
const itemDataServiceStub = {
|
||||
mapToCollection: () => of(new RestResponse(true, 200, 'OK'))
|
||||
};
|
||||
const activatedRouteStub = new ActivatedRouteStub({}, { collection: mockCollectionRD });
|
||||
const translateServiceStub = {
|
||||
get: () => of('test-message of collection ' + mockCollection.name),
|
||||
onLangChange: new EventEmitter(),
|
||||
onTranslationChange: new EventEmitter(),
|
||||
onDefaultLangChange: new EventEmitter()
|
||||
};
|
||||
const emptyList = new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), []));
|
||||
const searchServiceStub = Object.assign(new SearchServiceStub(), {
|
||||
search: () => of(emptyList),
|
||||
/* tslint:disable:no-empty */
|
||||
clearDiscoveryRequests: () => {}
|
||||
/* tslint:enable:no-empty */
|
||||
});
|
||||
const collectionDataServiceStub = {
|
||||
getMappedItems: () => of(emptyList),
|
||||
/* tslint:disable:no-empty */
|
||||
clearMappedItemsRequests: () => {}
|
||||
/* tslint:enable:no-empty */
|
||||
};
|
||||
const routeServiceStub = {
|
||||
getRouteParameterValue: () => {
|
||||
return observableOf('');
|
||||
},
|
||||
getQueryParameterValue: () => {
|
||||
return observableOf('')
|
||||
},
|
||||
getQueryParamsWithPrefix: () => {
|
||||
return observableOf('')
|
||||
}
|
||||
};
|
||||
const fixedFilterServiceStub = {
|
||||
getQueryByFilterName: () => {
|
||||
return observableOf('')
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [CollectionItemMapperComponent, ItemSelectComponent, SearchFormComponent, PaginationComponent, EnumKeysPipe, VarDirective, ErrorComponent, LoadingComponent],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||
{ provide: Router, useValue: routerStub },
|
||||
{ provide: SearchConfigurationService, useValue: searchConfigServiceStub },
|
||||
{ provide: SearchService, useValue: searchServiceStub },
|
||||
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
|
||||
{ provide: ItemDataService, useValue: itemDataServiceStub },
|
||||
{ provide: CollectionDataService, useValue: collectionDataServiceStub },
|
||||
{ provide: TranslateService, useValue: translateServiceStub },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||
{ provide: ObjectSelectService, useValue: new ObjectSelectServiceStub() },
|
||||
{ provide: RouteService, useValue: routeServiceStub },
|
||||
{ provide: SearchFixedFilterService, useValue: fixedFilterServiceStub }
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CollectionItemMapperComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
route = (comp as any).route;
|
||||
router = (comp as any).router;
|
||||
searchConfigService = (comp as any).searchConfigService;
|
||||
searchService = (comp as any).searchService;
|
||||
notificationsService = (comp as any).notificationsService;
|
||||
itemDataService = (comp as any).itemDataService;
|
||||
});
|
||||
|
||||
it('should display the correct collection name', () => {
|
||||
const name: HTMLElement = fixture.debugElement.query(By.css('#collection-name')).nativeElement;
|
||||
expect(name.innerHTML).toContain(mockCollection.name);
|
||||
});
|
||||
|
||||
describe('mapItems', () => {
|
||||
const ids = ['id1', 'id2', 'id3', 'id4'];
|
||||
|
||||
it('should display a success message if at least one mapping was successful', () => {
|
||||
comp.mapItems(ids);
|
||||
expect(notificationsService.success).toHaveBeenCalled();
|
||||
expect(notificationsService.error).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should display an error message if at least one mapping was unsuccessful', () => {
|
||||
spyOn(itemDataService, 'mapToCollection').and.returnValue(of(new RestResponse(false, 404, 'Not Found')));
|
||||
comp.mapItems(ids);
|
||||
expect(notificationsService.success).not.toHaveBeenCalled();
|
||||
expect(notificationsService.error).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('tabChange', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(routerStub, 'navigateByUrl');
|
||||
comp.tabChange({});
|
||||
});
|
||||
|
||||
it('should navigate to the same page to remove parameters', () => {
|
||||
expect(router.navigateByUrl).toHaveBeenCalledWith(url);
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildQuery', () => {
|
||||
const query = 'query';
|
||||
const expected = `-location.coll:\"${mockCollection.id}\" AND ${query}`;
|
||||
|
||||
let result;
|
||||
|
||||
beforeEach(() => {
|
||||
result = comp.buildQuery(mockCollection.id, query);
|
||||
});
|
||||
|
||||
it('should build a solr query to exclude the provided collection', () => {
|
||||
expect(result).toEqual(expected);
|
||||
})
|
||||
});
|
||||
|
||||
describe('onCancel', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(routerStub, 'navigate');
|
||||
comp.onCancel();
|
||||
});
|
||||
|
||||
it('should navigate to the collection page', () => {
|
||||
expect(router.navigate).toHaveBeenCalledWith(['/collections/', mockCollection.id]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -0,0 +1,256 @@
|
||||
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
||||
|
||||
import { ChangeDetectionStrategy, Component, Inject, OnInit, ViewChild } from '@angular/core';
|
||||
import { fadeIn, fadeInOut } from '../../shared/animations/fade';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { Collection } from '../../core/shared/collection.model';
|
||||
import { SearchConfigurationService } from '../../+search-page/search-service/search-configuration.service';
|
||||
import { PaginatedSearchOptions } from '../../+search-page/paginated-search-options.model';
|
||||
import { PaginatedList } from '../../core/data/paginated-list';
|
||||
import { map, startWith, switchMap, take, tap } from 'rxjs/operators';
|
||||
import { getRemoteDataPayload, getSucceededRemoteData, toDSpaceObjectListRD } from '../../core/shared/operators';
|
||||
import { SearchService } from '../../+search-page/search-service/search.service';
|
||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
import { DSpaceObjectType } from '../../core/shared/dspace-object-type.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { ItemDataService } from '../../core/data/item-data.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CollectionDataService } from '../../core/data/collection-data.service';
|
||||
import { isNotEmpty } from '../../shared/empty.util';
|
||||
import { RestResponse } from '../../core/cache/response.models';
|
||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||
import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-collection-item-mapper',
|
||||
styleUrls: ['./collection-item-mapper.component.scss'],
|
||||
templateUrl: './collection-item-mapper.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
animations: [
|
||||
fadeIn,
|
||||
fadeInOut
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
provide: SEARCH_CONFIG_SERVICE,
|
||||
useClass: SearchConfigurationService
|
||||
}
|
||||
]
|
||||
})
|
||||
/**
|
||||
* Component used to map items to a collection
|
||||
*/
|
||||
export class CollectionItemMapperComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* A view on the tabset element
|
||||
* Used to switch tabs programmatically
|
||||
*/
|
||||
@ViewChild('tabs') tabs;
|
||||
|
||||
/**
|
||||
* The collection to map items to
|
||||
*/
|
||||
collectionRD$: Observable<RemoteData<Collection>>;
|
||||
|
||||
/**
|
||||
* Search options
|
||||
*/
|
||||
searchOptions$: Observable<PaginatedSearchOptions>;
|
||||
|
||||
/**
|
||||
* List of items to show under the "Browse" tab
|
||||
* Items inside the collection
|
||||
*/
|
||||
collectionItemsRD$: Observable<RemoteData<PaginatedList<DSpaceObject>>>;
|
||||
|
||||
/**
|
||||
* List of items to show under the "Map" tab
|
||||
* Items outside the collection
|
||||
*/
|
||||
mappedItemsRD$: Observable<RemoteData<PaginatedList<DSpaceObject>>>;
|
||||
|
||||
/**
|
||||
* Sort on title ASC by default
|
||||
* @type {SortOptions}
|
||||
*/
|
||||
defaultSortOptions: SortOptions = new SortOptions('dc.title', SortDirection.ASC);
|
||||
|
||||
/**
|
||||
* Firing this observable (shouldUpdate$.next(true)) forces the two lists to reload themselves
|
||||
* Usually fired after the lists their cache is cleared (to force a new request to the REST API)
|
||||
*/
|
||||
shouldUpdate$: BehaviorSubject<boolean>;
|
||||
|
||||
/**
|
||||
* Track whether at least one search has been performed or not
|
||||
* As soon as at least one search has been performed, we display the search results
|
||||
*/
|
||||
performedSearch = false;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
@Inject(SEARCH_CONFIG_SERVICE) private searchConfigService: SearchConfigurationService,
|
||||
private searchService: SearchService,
|
||||
private notificationsService: NotificationsService,
|
||||
private itemDataService: ItemDataService,
|
||||
private collectionDataService: CollectionDataService,
|
||||
private translateService: TranslateService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.collectionRD$ = this.route.data.pipe(map((data) => data.collection)).pipe(getSucceededRemoteData()) as Observable<RemoteData<Collection>>;
|
||||
this.searchOptions$ = this.searchConfigService.paginatedSearchOptions;
|
||||
this.loadItemLists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load collectionItemsRD$ with a fixed scope to only obtain the items this collection owns
|
||||
* Load mappedItemsRD$ to only obtain items this collection doesn't own
|
||||
*/
|
||||
loadItemLists() {
|
||||
this.shouldUpdate$ = new BehaviorSubject<boolean>(true);
|
||||
const collectionAndOptions$ = observableCombineLatest(
|
||||
this.collectionRD$,
|
||||
this.searchOptions$,
|
||||
this.shouldUpdate$
|
||||
);
|
||||
this.collectionItemsRD$ = collectionAndOptions$.pipe(
|
||||
switchMap(([collectionRD, options, shouldUpdate]) => {
|
||||
if (shouldUpdate) {
|
||||
return this.collectionDataService.getMappedItems(collectionRD.payload.id, Object.assign(options, {
|
||||
sort: this.defaultSortOptions
|
||||
}))
|
||||
}
|
||||
})
|
||||
);
|
||||
this.mappedItemsRD$ = collectionAndOptions$.pipe(
|
||||
switchMap(([collectionRD, options, shouldUpdate]) => {
|
||||
if (shouldUpdate) {
|
||||
return this.searchService.search(Object.assign(new PaginatedSearchOptions(options), {
|
||||
query: this.buildQuery(collectionRD.payload.id, options.query),
|
||||
scope: undefined,
|
||||
dsoType: DSpaceObjectType.ITEM,
|
||||
sort: this.defaultSortOptions
|
||||
}), 10000).pipe(
|
||||
toDSpaceObjectListRD(),
|
||||
startWith(undefined)
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map/Unmap the selected items to the collection and display notifications
|
||||
* @param ids The list of item UUID's to map/unmap to the collection
|
||||
* @param remove Whether or not it's supposed to remove mappings
|
||||
*/
|
||||
mapItems(ids: string[], remove?: boolean) {
|
||||
const responses$ = this.collectionRD$.pipe(
|
||||
getSucceededRemoteData(),
|
||||
map((collectionRD: RemoteData<Collection>) => collectionRD.payload),
|
||||
switchMap((collection: Collection) =>
|
||||
observableCombineLatest(ids.map((id: string) =>
|
||||
remove ? this.itemDataService.removeMappingFromCollection(id, collection.id) : this.itemDataService.mapToCollection(id, collection.self)
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
this.showNotifications(responses$, remove);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display notifications
|
||||
* @param {Observable<RestResponse[]>} responses$ The responses after adding/removing a mapping
|
||||
* @param {boolean} remove Whether or not the goal was to remove mappings
|
||||
*/
|
||||
private showNotifications(responses$: Observable<RestResponse[]>, remove?: boolean) {
|
||||
const messageInsertion = remove ? 'unmap' : 'map';
|
||||
|
||||
responses$.subscribe((responses: RestResponse[]) => {
|
||||
const successful = responses.filter((response: RestResponse) => response.isSuccessful);
|
||||
const unsuccessful = responses.filter((response: RestResponse) => !response.isSuccessful);
|
||||
if (successful.length > 0) {
|
||||
const successMessages = observableCombineLatest(
|
||||
this.translateService.get(`collection.edit.item-mapper.notifications.${messageInsertion}.success.head`),
|
||||
this.translateService.get(`collection.edit.item-mapper.notifications.${messageInsertion}.success.content`, { amount: successful.length })
|
||||
);
|
||||
|
||||
successMessages.subscribe(([head, content]) => {
|
||||
this.notificationsService.success(head, content);
|
||||
});
|
||||
}
|
||||
if (unsuccessful.length > 0) {
|
||||
const unsuccessMessages = observableCombineLatest(
|
||||
this.translateService.get(`collection.edit.item-mapper.notifications.${messageInsertion}.error.head`),
|
||||
this.translateService.get(`collection.edit.item-mapper.notifications.${messageInsertion}.error.content`, { amount: unsuccessful.length })
|
||||
);
|
||||
|
||||
unsuccessMessages.subscribe(([head, content]) => {
|
||||
this.notificationsService.error(head, content);
|
||||
});
|
||||
}
|
||||
// Force an update on all lists and switch back to the first tab
|
||||
this.shouldUpdate$.next(true);
|
||||
this.switchToFirstTab();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear url parameters on tab change (temporary fix until pagination is improved)
|
||||
* @param event
|
||||
*/
|
||||
tabChange(event) {
|
||||
this.performedSearch = false;
|
||||
this.router.navigateByUrl(this.getCurrentUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current url without parameters
|
||||
* @returns {string}
|
||||
*/
|
||||
getCurrentUrl(): string {
|
||||
if (this.router.url.indexOf('?') > -1) {
|
||||
return this.router.url.substring(0, this.router.url.indexOf('?'));
|
||||
}
|
||||
return this.router.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a query where items that are already mapped to a collection are excluded from
|
||||
* @param collectionId The collection's UUID
|
||||
* @param query The query to add to it
|
||||
*/
|
||||
buildQuery(collectionId: string, query: string): string {
|
||||
const excludeColQuery = `-location.coll:\"${collectionId}\"`;
|
||||
if (isNotEmpty(query)) {
|
||||
return `${excludeColQuery} AND ${query}`;
|
||||
} else {
|
||||
return excludeColQuery;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the view to focus on the first tab
|
||||
*/
|
||||
switchToFirstTab() {
|
||||
this.tabs.select('browseTab');
|
||||
}
|
||||
|
||||
/**
|
||||
* When a cancel event is fired, return to the collection page
|
||||
*/
|
||||
onCancel() {
|
||||
this.collectionRD$.pipe(
|
||||
getSucceededRemoteData(),
|
||||
getRemoteDataPayload(),
|
||||
take(1)
|
||||
).subscribe((collection: Collection) => {
|
||||
this.router.navigate(['/collections/', collection.id])
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -9,6 +9,7 @@ import { CreateCollectionPageGuard } from './create-collection-page/create-colle
|
||||
import { DeleteCollectionPageComponent } from './delete-collection-page/delete-collection-page.component';
|
||||
import { URLCombiner } from '../core/url-combiner/url-combiner';
|
||||
import { getCollectionModulePath } from '../app-routing.module';
|
||||
import { CollectionItemMapperComponent } from './collection-item-mapper/collection-item-mapper.component';
|
||||
|
||||
export const COLLECTION_PARENT_PARAMETER = 'parent';
|
||||
|
||||
@@ -56,6 +57,15 @@ const COLLECTION_EDIT_PATH = ':id/edit';
|
||||
resolve: {
|
||||
collection: CollectionPageResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: ':id/edit/mapper',
|
||||
component: CollectionItemMapperComponent,
|
||||
pathMatch: 'full',
|
||||
resolve: {
|
||||
collection: CollectionPageResolver
|
||||
},
|
||||
canActivate: [AuthenticatedGuard]
|
||||
}
|
||||
])
|
||||
],
|
||||
|
@@ -3,18 +3,22 @@
|
||||
*ngVar="(collectionRD$ | async) as collectionRD">
|
||||
<div *ngIf="collectionRD?.hasSucceeded" @fadeInOut>
|
||||
<div *ngIf="collectionRD?.payload as collection">
|
||||
<header class="comcol-header border-bottom mb-4 pb-4">
|
||||
<!-- Collection logo -->
|
||||
<ds-comcol-page-logo *ngIf="logoRD$"
|
||||
[logo]="(logoRD$ | async)?.payload" [alternateText]="'Collection Logo'">
|
||||
[alternateText]="'Collection Logo'">
|
||||
</ds-comcol-page-logo>
|
||||
<!-- Collection Name -->
|
||||
<ds-comcol-page-header
|
||||
[name]="collection.name">
|
||||
</ds-comcol-page-header>
|
||||
<!-- Browse-By Links -->
|
||||
<ds-comcol-page-browse-by [id]="collection.id"></ds-comcol-page-browse-by>
|
||||
<!-- Collection logo -->
|
||||
<ds-comcol-page-logo *ngIf="logoRD$"
|
||||
[logo]="(logoRD$ | async)?.payload"
|
||||
[alternateText]="'Collection Logo'">
|
||||
</ds-comcol-page-logo>
|
||||
<!-- Introductionary text -->
|
||||
<!-- Handle -->
|
||||
<ds-comcol-page-handle
|
||||
[content]="collection.handle"
|
||||
[title]="'collection.page.handle'" >
|
||||
</ds-comcol-page-handle>
|
||||
<!-- Introductory text -->
|
||||
<ds-comcol-page-content
|
||||
[content]="collection.introductoryText"
|
||||
[hasInnerHtml]="true">
|
||||
@@ -23,23 +27,20 @@
|
||||
<ds-comcol-page-content
|
||||
[content]="collection.sidebarText"
|
||||
[hasInnerHtml]="true"
|
||||
[title]="'community.page.news'">
|
||||
[title]="'collection.page.news'">
|
||||
</ds-comcol-page-content>
|
||||
<!-- Copyright -->
|
||||
<ds-comcol-page-content
|
||||
[content]="collection.copyrightText"
|
||||
[hasInnerHtml]="true">
|
||||
</ds-comcol-page-content>
|
||||
<!-- Licence -->
|
||||
<ds-comcol-page-content
|
||||
[content]="collection.dcLicense"
|
||||
[title]="'collection.page.license'">
|
||||
</ds-comcol-page-content>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
</header>
|
||||
<section class="comcol-page-browse-section">
|
||||
<!-- Browse-By Links -->
|
||||
<ds-comcol-page-browse-by
|
||||
[id]="collection.id"
|
||||
[contentType]="collection.type">
|
||||
</ds-comcol-page-browse-by>
|
||||
|
||||
<ng-container *ngVar="(itemRD$ | async) as itemRD">
|
||||
<div *ngIf="itemRD?.hasSucceeded" @fadeIn>
|
||||
<h2>{{'collection.page.browse.recent.head' | translate}}</h2>
|
||||
<div class="mt-4" *ngIf="itemRD?.hasSucceeded" @fadeIn>
|
||||
<h3 class="sr-only">{{'collection.page.browse.recent.head' | translate}}</h3>
|
||||
<ds-viewable-collection
|
||||
[config]="paginationConfig"
|
||||
[sortConfig]="sortConfig"
|
||||
@@ -52,11 +53,23 @@
|
||||
message="{{'error.recent-submissions' | translate}}"></ds-error>
|
||||
<ds-loading *ngIf="!itemRD || itemRD.isLoading"
|
||||
message="{{'loading.recent-submissions' | translate}}"></ds-loading>
|
||||
<div *ngIf="!itemRD?.isLoading && itemRD?.payload?.page.length === 0" class="alert alert-info w-100" role="alert">
|
||||
{{'collection.page.browse.recent.empty' | translate}}
|
||||
</div>
|
||||
</ng-container>
|
||||
</div>
|
||||
<ds-error *ngIf="collectionRD?.hasFailed"
|
||||
message="{{'error.collection' | translate}}"></ds-error>
|
||||
<ds-loading *ngIf="collectionRD?.isLoading"
|
||||
message="{{'loading.collection' | translate}}"></ds-loading>
|
||||
</section>
|
||||
<footer *ngIf="collection.copyrightText" class="border-top my-5 pt-4">
|
||||
<!-- Copyright -->
|
||||
<ds-comcol-page-content
|
||||
[content]="collection.copyrightText"
|
||||
[hasInnerHtml]="true">
|
||||
</ds-comcol-page-content>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
<ds-error *ngIf="collectionRD?.hasFailed"
|
||||
message="{{'error.collection' | translate}}"></ds-error>
|
||||
<ds-loading *ngIf="collectionRD?.isLoading"
|
||||
message="{{'loading.collection' | translate}}"></ds-loading>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -9,6 +9,8 @@ import { CreateCollectionPageComponent } from './create-collection-page/create-c
|
||||
import { CollectionFormComponent } from './collection-form/collection-form.component';
|
||||
import { DeleteCollectionPageComponent } from './delete-collection-page/delete-collection-page.component';
|
||||
import { SearchService } from '../+search-page/search-service/search.service';
|
||||
import { CollectionItemMapperComponent } from './collection-item-mapper/collection-item-mapper.component';
|
||||
import { SearchFixedFilterService } from '../+search-page/search-filters/search-filter/search-fixed-filter.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -20,13 +22,15 @@ import { SearchService } from '../+search-page/search-service/search.service';
|
||||
CollectionPageComponent,
|
||||
CreateCollectionPageComponent,
|
||||
DeleteCollectionPageComponent,
|
||||
CollectionFormComponent
|
||||
CollectionFormComponent,
|
||||
CollectionItemMapperComponent
|
||||
],
|
||||
exports: [
|
||||
CollectionFormComponent
|
||||
],
|
||||
providers: [
|
||||
SearchService
|
||||
SearchService,
|
||||
SearchFixedFilterService
|
||||
]
|
||||
})
|
||||
export class CollectionPageModule {
|
||||
|
@@ -4,7 +4,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { RouteService } from '../../shared/services/route.service';
|
||||
import { RouteService } from '../../core/services/route.service';
|
||||
import { SharedModule } from '../../shared/shared.module';
|
||||
import { CollectionDataService } from '../../core/data/collection-data.service';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { CommunityDataService } from '../../core/data/community-data.service';
|
||||
import { RouteService } from '../../shared/services/route.service';
|
||||
import { RouteService } from '../../core/services/route.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { CreateComColPageComponent } from '../../shared/comcol-forms/create-comcol-page/create-comcol-page.component';
|
||||
import { Collection } from '../../core/shared/collection.model';
|
||||
|
@@ -1,33 +1,38 @@
|
||||
<div class="container" *ngVar="(communityRD$ | async) as communityRD">
|
||||
<div class="community-page" *ngIf="communityRD?.hasSucceeded" @fadeInOut>
|
||||
<div *ngIf="communityRD?.payload; let communityPayload">
|
||||
<!-- Community name -->
|
||||
<ds-comcol-page-header [name]="communityPayload.name"></ds-comcol-page-header>
|
||||
<!-- Browse-By Links -->
|
||||
<ds-comcol-page-browse-by [id]="communityPayload.id"></ds-comcol-page-browse-by>
|
||||
<!-- Community logo -->
|
||||
<ds-comcol-page-logo *ngIf="logoRD$"
|
||||
[logo]="(logoRD$ | async)?.payload"
|
||||
[alternateText]="'Community Logo'">
|
||||
</ds-comcol-page-logo>
|
||||
<!-- Introductory text -->
|
||||
<ds-comcol-page-content
|
||||
[content]="communityPayload.introductoryText"
|
||||
[hasInnerHtml]="true">
|
||||
</ds-comcol-page-content>
|
||||
<!-- News -->
|
||||
<ds-comcol-page-content
|
||||
[content]="communityPayload.sidebarText"
|
||||
[hasInnerHtml]="true"
|
||||
[title]="'community.page.news'">
|
||||
</ds-comcol-page-content>
|
||||
<!-- Copyright -->
|
||||
<ds-comcol-page-content
|
||||
[content]="communityPayload.copyrightText"
|
||||
[hasInnerHtml]="true">
|
||||
</ds-comcol-page-content>
|
||||
<ds-community-page-sub-community-list [community]="communityPayload"></ds-community-page-sub-community-list>
|
||||
<ds-community-page-sub-collection-list [community]="communityPayload"></ds-community-page-sub-collection-list>
|
||||
<header class="comcol-header border-bottom mb-4 pb-4">
|
||||
<!-- Community logo -->
|
||||
<ds-comcol-page-logo *ngIf="logoRD$" [logo]="(logoRD$ | async)?.payload" [alternateText]="'Community Logo'">
|
||||
</ds-comcol-page-logo>
|
||||
|
||||
<!-- Community name -->
|
||||
<ds-comcol-page-header [name]="communityPayload.name"></ds-comcol-page-header>
|
||||
<!-- Handle -->
|
||||
<ds-comcol-page-handle [content]="communityPayload.handle" [title]="'community.page.handle'">
|
||||
</ds-comcol-page-handle>
|
||||
<!-- Introductory text -->
|
||||
<ds-comcol-page-content [content]="communityPayload.introductoryText" [hasInnerHtml]="true">
|
||||
</ds-comcol-page-content>
|
||||
<!-- News -->
|
||||
<ds-comcol-page-content [content]="communityPayload.sidebarText" [hasInnerHtml]="true"
|
||||
[title]="'community.page.news'">
|
||||
</ds-comcol-page-content>
|
||||
|
||||
</header>
|
||||
<section class="comcol-page-browse-section">
|
||||
<!-- Browse-By Links -->
|
||||
<ds-comcol-page-browse-by [id]="communityPayload.id" [contentType]="communityPayload.type">
|
||||
</ds-comcol-page-browse-by>
|
||||
|
||||
<ds-community-page-sub-community-list [community]="communityPayload"></ds-community-page-sub-community-list>
|
||||
<ds-community-page-sub-collection-list [community]="communityPayload"></ds-community-page-sub-collection-list>
|
||||
</section>
|
||||
<footer *ngIf="communityPayload.copyrightText" class="border-top my-5 pt-4">
|
||||
<!-- Copyright -->
|
||||
<ds-comcol-page-content [content]="communityPayload.copyrightText" [hasInnerHtml]="true">
|
||||
</ds-comcol-page-content>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { RouteService } from '../../shared/services/route.service';
|
||||
import { RouteService } from '../../core/services/route.service';
|
||||
import { SharedModule } from '../../shared/shared.module';
|
||||
import { CollectionDataService } from '../../core/data/collection-data.service';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Community } from '../../core/shared/community.model';
|
||||
import { CommunityDataService } from '../../core/data/community-data.service';
|
||||
import { RouteService } from '../../shared/services/route.service';
|
||||
import { RouteService } from '../../core/services/route.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { CreateComColPageComponent } from '../../shared/comcol-forms/create-comcol-page/create-comcol-page.component';
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { RouteService } from '../../shared/services/route.service';
|
||||
import { RouteService } from '../../core/services/route.service';
|
||||
import { SharedModule } from '../../shared/shared.module';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
|
@@ -0,0 +1,179 @@
|
||||
import { Component, Inject, Injectable, OnInit } from '@angular/core';
|
||||
import { FieldUpdate, FieldUpdates } from '../../../core/data/object-updates/object-updates.reducer';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { ObjectUpdatesService } from '../../../core/data/object-updates/object-updates.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config';
|
||||
import { first, map } from 'rxjs/operators';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
|
||||
@Injectable()
|
||||
/**
|
||||
* Abstract component for managing object updates of an item
|
||||
*/
|
||||
export abstract class AbstractItemUpdateComponent implements OnInit {
|
||||
/**
|
||||
* The item to display the edit page for
|
||||
*/
|
||||
item: Item;
|
||||
/**
|
||||
* The current values and updates for all this item's fields
|
||||
* Should be initialized in the initializeUpdates method of the child component
|
||||
*/
|
||||
updates$: Observable<FieldUpdates>;
|
||||
/**
|
||||
* The current url of this page
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* Prefix for this component's notification translate keys
|
||||
* Should be initialized in the initializeNotificationsPrefix method of the child component
|
||||
*/
|
||||
notificationsPrefix;
|
||||
/**
|
||||
* The time span for being able to undo discarding changes
|
||||
*/
|
||||
discardTimeOut: number;
|
||||
|
||||
constructor(
|
||||
protected itemService: ItemDataService,
|
||||
protected objectUpdatesService: ObjectUpdatesService,
|
||||
protected router: Router,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected translateService: TranslateService,
|
||||
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||
protected route: ActivatedRoute
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize common properties between item-update components
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.route.parent.data.pipe(map((data) => data.item))
|
||||
.pipe(
|
||||
first(),
|
||||
map((data: RemoteData<Item>) => data.payload)
|
||||
).subscribe((item: Item) => {
|
||||
this.item = item;
|
||||
});
|
||||
|
||||
this.discardTimeOut = this.EnvConfig.item.edit.undoTimeout;
|
||||
this.url = this.router.url;
|
||||
if (this.url.indexOf('?') > 0) {
|
||||
this.url = this.url.substr(0, this.url.indexOf('?'));
|
||||
}
|
||||
this.hasChanges().pipe(first()).subscribe((hasChanges) => {
|
||||
if (!hasChanges) {
|
||||
this.initializeOriginalFields();
|
||||
} else {
|
||||
this.checkLastModified();
|
||||
}
|
||||
});
|
||||
|
||||
this.initializeNotificationsPrefix();
|
||||
this.initializeUpdates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the values and updates of the current item's fields
|
||||
*/
|
||||
abstract initializeUpdates(): void;
|
||||
|
||||
/**
|
||||
* Initialize the prefix for notification messages
|
||||
*/
|
||||
abstract initializeNotificationsPrefix(): void;
|
||||
|
||||
/**
|
||||
* Sends all initial values of this item to the object updates service
|
||||
*/
|
||||
abstract initializeOriginalFields(): void;
|
||||
|
||||
/**
|
||||
* Prevent unnecessary rerendering so fields don't lose focus
|
||||
*/
|
||||
trackUpdate(index, update: FieldUpdate) {
|
||||
return update && update.field ? update.field.uuid : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not there are currently updates for this item
|
||||
*/
|
||||
hasChanges(): Observable<boolean> {
|
||||
return this.objectUpdatesService.hasUpdates(this.url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current page is entirely valid
|
||||
*/
|
||||
protected isValid() {
|
||||
return this.objectUpdatesService.isValidPage(this.url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current item is still in sync with the version in the store
|
||||
* If it's not, a notification is shown and the changes are removed
|
||||
*/
|
||||
private checkLastModified() {
|
||||
const currentVersion = this.item.lastModified;
|
||||
this.objectUpdatesService.getLastModified(this.url).pipe(first()).subscribe(
|
||||
(updateVersion: Date) => {
|
||||
if (updateVersion.getDate() !== currentVersion.getDate()) {
|
||||
this.notificationsService.warning(this.getNotificationTitle('outdated'), this.getNotificationContent('outdated'));
|
||||
this.initializeOriginalFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the current changes
|
||||
*/
|
||||
abstract submit(): void;
|
||||
|
||||
/**
|
||||
* Request the object updates service to discard all current changes to this item
|
||||
* Shows a notification to remind the user that they can undo this
|
||||
*/
|
||||
discard() {
|
||||
const undoNotification = this.notificationsService.info(this.getNotificationTitle('discarded'), this.getNotificationContent('discarded'), { timeOut: this.discardTimeOut });
|
||||
this.objectUpdatesService.discardFieldUpdates(this.url, undoNotification);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the object updates service to undo discarding all changes to this item
|
||||
*/
|
||||
reinstate() {
|
||||
this.objectUpdatesService.reinstateFieldUpdates(this.url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not the item is currently reinstatable
|
||||
*/
|
||||
isReinstatable(): Observable<boolean> {
|
||||
return this.objectUpdatesService.isReinstatable(this.url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translated notification title
|
||||
* @param key
|
||||
*/
|
||||
protected getNotificationTitle(key: string) {
|
||||
return this.translateService.instant(this.notificationsPrefix + key + '.title');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translated notification content
|
||||
* @param key
|
||||
*/
|
||||
protected getNotificationContent(key: string) {
|
||||
return this.translateService.instant(this.notificationsPrefix + key + '.content');
|
||||
|
||||
}
|
||||
}
|
@@ -15,6 +15,12 @@ import { ItemDeleteComponent } from './item-delete/item-delete.component';
|
||||
import { ItemMetadataComponent } from './item-metadata/item-metadata.component';
|
||||
import { EditInPlaceFieldComponent } from './item-metadata/edit-in-place-field/edit-in-place-field.component';
|
||||
import { ItemBitstreamsComponent } from './item-bitstreams/item-bitstreams.component';
|
||||
import { SearchPageModule } from '../../+search-page/search-page.module';
|
||||
import { ItemCollectionMapperComponent } from './item-collection-mapper/item-collection-mapper.component';
|
||||
import { ItemRelationshipsComponent } from './item-relationships/item-relationships.component';
|
||||
import { EditRelationshipComponent } from './item-relationships/edit-relationship/edit-relationship.component';
|
||||
import { EditRelationshipListComponent } from './item-relationships/edit-relationship-list/edit-relationship-list.component';
|
||||
import { ItemMoveComponent } from './item-move/item-move.component';
|
||||
|
||||
/**
|
||||
* Module that contains all components related to the Edit Item page administrator functionality
|
||||
@@ -23,7 +29,8 @@ import { ItemBitstreamsComponent } from './item-bitstreams/item-bitstreams.compo
|
||||
imports: [
|
||||
CommonModule,
|
||||
SharedModule,
|
||||
EditItemPageRoutingModule
|
||||
EditItemPageRoutingModule,
|
||||
SearchPageModule
|
||||
],
|
||||
declarations: [
|
||||
EditItemPageComponent,
|
||||
@@ -37,8 +44,13 @@ import { ItemBitstreamsComponent } from './item-bitstreams/item-bitstreams.compo
|
||||
ItemDeleteComponent,
|
||||
ItemStatusComponent,
|
||||
ItemMetadataComponent,
|
||||
ItemRelationshipsComponent,
|
||||
ItemBitstreamsComponent,
|
||||
EditInPlaceFieldComponent
|
||||
EditInPlaceFieldComponent,
|
||||
EditRelationshipComponent,
|
||||
EditRelationshipListComponent,
|
||||
ItemCollectionMapperComponent,
|
||||
ItemMoveComponent,
|
||||
]
|
||||
})
|
||||
export class EditItemPageModule {
|
||||
|
@@ -10,12 +10,16 @@ import { ItemDeleteComponent } from './item-delete/item-delete.component';
|
||||
import { ItemStatusComponent } from './item-status/item-status.component';
|
||||
import { ItemMetadataComponent } from './item-metadata/item-metadata.component';
|
||||
import { ItemBitstreamsComponent } from './item-bitstreams/item-bitstreams.component';
|
||||
import { ItemCollectionMapperComponent } from './item-collection-mapper/item-collection-mapper.component';
|
||||
import { ItemMoveComponent } from './item-move/item-move.component';
|
||||
import { ItemRelationshipsComponent } from './item-relationships/item-relationships.component';
|
||||
|
||||
const ITEM_EDIT_WITHDRAW_PATH = 'withdraw';
|
||||
const ITEM_EDIT_REINSTATE_PATH = 'reinstate';
|
||||
const ITEM_EDIT_PRIVATE_PATH = 'private';
|
||||
const ITEM_EDIT_PUBLIC_PATH = 'public';
|
||||
const ITEM_EDIT_DELETE_PATH = 'delete';
|
||||
const ITEM_EDIT_MOVE_PATH = 'move';
|
||||
|
||||
/**
|
||||
* Routing module that handles the routing for the Edit Item page administrator functionality
|
||||
@@ -50,6 +54,11 @@ const ITEM_EDIT_DELETE_PATH = 'delete';
|
||||
component: ItemMetadataComponent,
|
||||
data: { title: 'item.edit.tabs.metadata.title' }
|
||||
},
|
||||
{
|
||||
path: 'relationships',
|
||||
component: ItemRelationshipsComponent,
|
||||
data: { title: 'item.edit.tabs.relationships.title' }
|
||||
},
|
||||
{
|
||||
path: 'view',
|
||||
/* TODO - change when view page exists */
|
||||
@@ -64,6 +73,13 @@ const ITEM_EDIT_DELETE_PATH = 'delete';
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'mapper',
|
||||
component: ItemCollectionMapperComponent,
|
||||
resolve: {
|
||||
item: ItemPageResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: ITEM_EDIT_WITHDRAW_PATH,
|
||||
component: ItemWithdrawComponent,
|
||||
@@ -98,6 +114,14 @@ const ITEM_EDIT_DELETE_PATH = 'delete';
|
||||
resolve: {
|
||||
item: ItemPageResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: ITEM_EDIT_MOVE_PATH,
|
||||
component: ItemMoveComponent,
|
||||
data: { title: 'item.edit.move.title' },
|
||||
resolve: {
|
||||
item: ItemPageResolver
|
||||
}
|
||||
}])
|
||||
],
|
||||
providers: [
|
||||
|
@@ -0,0 +1,56 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h2>{{'item.edit.item-mapper.head' | translate}}</h2>
|
||||
<p [innerHTML]="'item.edit.item-mapper.item' | translate:{ name: (itemRD$ | async)?.payload?.name }" id="item-name"></p>
|
||||
<p>{{'item.edit.item-mapper.description' | translate}}</p>
|
||||
|
||||
<ngb-tabset (tabChange)="tabChange($event)" [destroyOnHide]="true" #tabs="ngbTabset">
|
||||
<ngb-tab title="{{'item.edit.item-mapper.tabs.browse' | translate}}" id="browseTab">
|
||||
<ng-template ngbTabContent>
|
||||
<div class="mt-2">
|
||||
<ds-collection-select class="mt-2"
|
||||
[key]="'browse'"
|
||||
[dsoRD$]="itemCollectionsRD$"
|
||||
[paginationOptions]="(searchOptions$ | async)?.pagination"
|
||||
[confirmButton]="'item.edit.item-mapper.buttons.remove'"
|
||||
[cancelButton]="'item.edit.item-mapper.cancel'"
|
||||
[dangerConfirm]="true"
|
||||
(confirm)="removeMappings($event)"
|
||||
(cancel)="onCancel()"></ds-collection-select>
|
||||
</div>
|
||||
</ng-template>
|
||||
</ngb-tab>
|
||||
<ngb-tab title="{{'item.edit.item-mapper.tabs.map' | translate}}" id="mapTab">
|
||||
<ng-template ngbTabContent>
|
||||
<div class="row mt-2">
|
||||
<div class="col-12 col-lg-6">
|
||||
<ds-search-form id="search-form"
|
||||
[query]="(searchOptions$ | async)?.query"
|
||||
[currentUrl]="'./'"
|
||||
[inPlaceSearch]="true"
|
||||
(submitSearch)="performedSearch = true">
|
||||
</ds-search-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="performedSearch">
|
||||
<ds-collection-select class="mt-2"
|
||||
[key]="'map'"
|
||||
[dsoRD$]="mappedCollectionsRD$"
|
||||
[paginationOptions]="(searchOptions$ | async)?.pagination"
|
||||
[sortOptions]="(searchOptions$ | async)?.sort"
|
||||
[confirmButton]="'item.edit.item-mapper.buttons.add'"
|
||||
[cancelButton]="'item.edit.item-mapper.cancel'"
|
||||
(confirm)="mapCollections($event)"
|
||||
(cancel)="onCancel()"></ds-collection-select>
|
||||
</div>
|
||||
<div *ngIf="!performedSearch" class="alert alert-info w-100" role="alert">
|
||||
{{'item.edit.item-mapper.no-search' | translate}}
|
||||
</div>
|
||||
</ng-template>
|
||||
</ngb-tab>
|
||||
</ngb-tabset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,207 @@
|
||||
import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ItemCollectionMapperComponent } from './item-collection-mapper.component';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { SearchConfigurationService } from '../../../+search-page/search-service/search-configuration.service';
|
||||
import { SearchService } from '../../../+search-page/search-service/search.service';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PaginatedSearchOptions } from '../../../+search-page/paginated-search-options.model';
|
||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { RouterStub } from '../../../shared/testing/router-stub';
|
||||
import { ActivatedRouteStub } from '../../../shared/testing/active-router-stub';
|
||||
import { EventEmitter } from '@angular/core';
|
||||
import { SearchServiceStub } from '../../../shared/testing/search-service-stub';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../core/shared/page-info.model';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { SharedModule } from '../../../shared/shared.module';
|
||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service-stub';
|
||||
import { HostWindowService } from '../../../shared/host-window.service';
|
||||
import { HostWindowServiceStub } from '../../../shared/testing/host-window-service-stub';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { ObjectSelectService } from '../../../shared/object-select/object-select.service';
|
||||
import { ObjectSelectServiceStub } from '../../../shared/testing/object-select-service-stub';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { of } from 'rxjs/internal/observable/of';
|
||||
import { RestResponse } from '../../../core/cache/response.models';
|
||||
import { CollectionSelectComponent } from '../../../shared/object-select/collection-select/collection-select.component';
|
||||
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
|
||||
import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe';
|
||||
import { VarDirective } from '../../../shared/utils/var.directive';
|
||||
import { SearchFormComponent } from '../../../shared/search-form/search-form.component';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { ErrorComponent } from '../../../shared/error/error.component';
|
||||
import { LoadingComponent } from '../../../shared/loading/loading.component';
|
||||
|
||||
describe('ItemCollectionMapperComponent', () => {
|
||||
let comp: ItemCollectionMapperComponent;
|
||||
let fixture: ComponentFixture<ItemCollectionMapperComponent>;
|
||||
|
||||
let route: ActivatedRoute;
|
||||
let router: Router;
|
||||
let searchConfigService: SearchConfigurationService;
|
||||
let searchService: SearchService;
|
||||
let notificationsService: NotificationsService;
|
||||
let itemDataService: ItemDataService;
|
||||
|
||||
const mockCollection = Object.assign(new Collection(), { id: 'collection1' });
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
id: '932c7d50-d85a-44cb-b9dc-b427b12877bd',
|
||||
name: 'test-item'
|
||||
});
|
||||
const mockItemRD: RemoteData<Item> = new RemoteData<Item>(false, false, true, null, mockItem);
|
||||
const mockSearchOptions = of(new PaginatedSearchOptions({
|
||||
pagination: Object.assign(new PaginationComponentOptions(), {
|
||||
id: 'search-page-configuration',
|
||||
pageSize: 10,
|
||||
currentPage: 1
|
||||
}),
|
||||
sort: new SortOptions('dc.title', SortDirection.ASC)
|
||||
}));
|
||||
const url = 'http://test.url';
|
||||
const urlWithParam = url + '?param=value';
|
||||
const routerStub = Object.assign(new RouterStub(), {
|
||||
url: urlWithParam,
|
||||
navigateByUrl: {},
|
||||
navigate: {}
|
||||
});
|
||||
const searchConfigServiceStub = {
|
||||
paginatedSearchOptions: mockSearchOptions
|
||||
};
|
||||
const mockCollectionsRD = new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), []));
|
||||
const itemDataServiceStub = {
|
||||
mapToCollection: () => of(new RestResponse(true, 200, 'OK')),
|
||||
removeMappingFromCollection: () => of(new RestResponse(true, 200, 'OK')),
|
||||
getMappedCollections: () => of(mockCollectionsRD),
|
||||
/* tslint:disable:no-empty */
|
||||
clearMappedCollectionsRequests: () => {}
|
||||
/* tslint:enable:no-empty */
|
||||
};
|
||||
const searchServiceStub = Object.assign(new SearchServiceStub(), {
|
||||
search: () => of(mockCollectionsRD),
|
||||
/* tslint:disable:no-empty */
|
||||
clearDiscoveryRequests: () => {}
|
||||
/* tslint:enable:no-empty */
|
||||
});
|
||||
const activatedRouteStub = new ActivatedRouteStub({}, { item: mockItemRD });
|
||||
const translateServiceStub = {
|
||||
get: () => of('test-message of item ' + mockItem.name),
|
||||
onLangChange: new EventEmitter(),
|
||||
onTranslationChange: new EventEmitter(),
|
||||
onDefaultLangChange: new EventEmitter()
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [ItemCollectionMapperComponent, CollectionSelectComponent, SearchFormComponent, PaginationComponent, EnumKeysPipe, VarDirective, ErrorComponent, LoadingComponent],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||
{ provide: Router, useValue: routerStub },
|
||||
{ provide: SearchConfigurationService, useValue: searchConfigServiceStub },
|
||||
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
|
||||
{ provide: ItemDataService, useValue: itemDataServiceStub },
|
||||
{ provide: SearchService, useValue: searchServiceStub },
|
||||
{ provide: ObjectSelectService, useValue: new ObjectSelectServiceStub() },
|
||||
{ provide: TranslateService, useValue: translateServiceStub },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) }
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ItemCollectionMapperComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
route = (comp as any).route;
|
||||
router = (comp as any).router;
|
||||
searchConfigService = (comp as any).searchConfigService;
|
||||
notificationsService = (comp as any).notificationsService;
|
||||
itemDataService = (comp as any).itemDataService;
|
||||
searchService = (comp as any).searchService;
|
||||
});
|
||||
|
||||
it('should display the correct collection name', () => {
|
||||
const name: HTMLElement = fixture.debugElement.query(By.css('#item-name')).nativeElement;
|
||||
expect(name.innerHTML).toContain(mockItem.name);
|
||||
});
|
||||
|
||||
describe('mapCollections', () => {
|
||||
const ids = ['id1', 'id2', 'id3', 'id4'];
|
||||
|
||||
it('should display a success message if at least one mapping was successful', () => {
|
||||
comp.mapCollections(ids);
|
||||
expect(notificationsService.success).toHaveBeenCalled();
|
||||
expect(notificationsService.error).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should display an error message if at least one mapping was unsuccessful', () => {
|
||||
spyOn(itemDataService, 'mapToCollection').and.returnValue(of(new RestResponse(false, 404, 'Not Found')));
|
||||
comp.mapCollections(ids);
|
||||
expect(notificationsService.success).not.toHaveBeenCalled();
|
||||
expect(notificationsService.error).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeMappings', () => {
|
||||
const ids = ['id1', 'id2', 'id3', 'id4'];
|
||||
|
||||
it('should display a success message if the removal of at least one mapping was successful', () => {
|
||||
comp.removeMappings(ids);
|
||||
expect(notificationsService.success).toHaveBeenCalled();
|
||||
expect(notificationsService.error).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should display an error message if the removal of at least one mapping was unsuccessful', () => {
|
||||
spyOn(itemDataService, 'removeMappingFromCollection').and.returnValue(of(new RestResponse(false, 404, 'Not Found')));
|
||||
comp.removeMappings(ids);
|
||||
expect(notificationsService.success).not.toHaveBeenCalled();
|
||||
expect(notificationsService.error).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('tabChange', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(routerStub, 'navigateByUrl');
|
||||
comp.tabChange({});
|
||||
});
|
||||
|
||||
it('should navigate to the same page to remove parameters', () => {
|
||||
expect(router.navigateByUrl).toHaveBeenCalledWith(url);
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildQuery', () => {
|
||||
const query = 'query';
|
||||
const expected = `${query} AND -search.resourceid:${mockCollection.id}`;
|
||||
|
||||
let result;
|
||||
|
||||
beforeEach(() => {
|
||||
result = comp.buildQuery([mockCollection], query);
|
||||
});
|
||||
|
||||
it('should build a solr query to exclude the provided collection', () => {
|
||||
expect(result).toEqual(expected);
|
||||
})
|
||||
});
|
||||
|
||||
describe('onCancel', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(routerStub, 'navigate');
|
||||
comp.onCancel();
|
||||
});
|
||||
|
||||
it('should navigate to the item page', () => {
|
||||
expect(router.navigate).toHaveBeenCalledWith(['/items/', mockItem.id]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -0,0 +1,283 @@
|
||||
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
||||
|
||||
import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { fadeIn, fadeInOut } from '../../../shared/animations/fade';
|
||||
import { PaginatedSearchOptions } from '../../../+search-page/paginated-search-options.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { getRemoteDataPayload, getSucceededRemoteData, toDSpaceObjectListRD } from '../../../core/shared/operators';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { SearchService } from '../../../+search-page/search-service/search.service';
|
||||
import { SearchConfigurationService } from '../../../+search-page/search-service/search-configuration.service';
|
||||
import { map, startWith, switchMap, take } from 'rxjs/operators';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||
import { isNotEmpty } from '../../../shared/empty.util';
|
||||
import { RestResponse } from '../../../core/cache/response.models';
|
||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-collection-mapper',
|
||||
styleUrls: ['./item-collection-mapper.component.scss'],
|
||||
templateUrl: './item-collection-mapper.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
animations: [
|
||||
fadeIn,
|
||||
fadeInOut
|
||||
]
|
||||
})
|
||||
/**
|
||||
* Component for mapping collections to an item
|
||||
*/
|
||||
export class ItemCollectionMapperComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* A view on the tabset element
|
||||
* Used to switch tabs programmatically
|
||||
*/
|
||||
@ViewChild('tabs') tabs;
|
||||
|
||||
/**
|
||||
* The item to map to collections
|
||||
*/
|
||||
itemRD$: Observable<RemoteData<Item>>;
|
||||
|
||||
/**
|
||||
* Search options
|
||||
*/
|
||||
searchOptions$: Observable<PaginatedSearchOptions>;
|
||||
|
||||
/**
|
||||
* List of collections to show under the "Browse" tab
|
||||
* Collections that are mapped to the item
|
||||
*/
|
||||
itemCollectionsRD$: Observable<RemoteData<PaginatedList<Collection>>>;
|
||||
|
||||
/**
|
||||
* List of collections to show under the "Map" tab
|
||||
* Collections that are not mapped to the item
|
||||
*/
|
||||
mappedCollectionsRD$: Observable<RemoteData<PaginatedList<Collection>>>;
|
||||
|
||||
/**
|
||||
* Firing this observable (shouldUpdate$.next(true)) forces the two lists to reload themselves
|
||||
* Usually fired after the lists their cache is cleared (to force a new request to the REST API)
|
||||
*/
|
||||
shouldUpdate$: BehaviorSubject<boolean>;
|
||||
|
||||
/**
|
||||
* Track whether at least one search has been performed or not
|
||||
* As soon as at least one search has been performed, we display the search results
|
||||
*/
|
||||
performedSearch = false;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private searchConfigService: SearchConfigurationService,
|
||||
private searchService: SearchService,
|
||||
private notificationsService: NotificationsService,
|
||||
private itemDataService: ItemDataService,
|
||||
private translateService: TranslateService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.itemRD$ = this.route.data.pipe(map((data) => data.item)).pipe(getSucceededRemoteData()) as Observable<RemoteData<Item>>;
|
||||
this.searchOptions$ = this.searchConfigService.paginatedSearchOptions;
|
||||
this.loadCollectionLists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load itemCollectionsRD$ with a fixed scope to only obtain the collections that own this item
|
||||
* Load mappedCollectionsRD$ to only obtain collections that don't own this item
|
||||
*/
|
||||
loadCollectionLists() {
|
||||
this.shouldUpdate$ = new BehaviorSubject<boolean>(true);
|
||||
this.itemCollectionsRD$ = observableCombineLatest(this.itemRD$, this.shouldUpdate$).pipe(
|
||||
map(([itemRD, shouldUpdate]) => {
|
||||
if (shouldUpdate) {
|
||||
return itemRD.payload
|
||||
}
|
||||
}),
|
||||
switchMap((item: Item) => this.itemDataService.getMappedCollections(item.id))
|
||||
);
|
||||
|
||||
const owningCollectionRD$ = this.itemRD$.pipe(
|
||||
switchMap((itemRD: RemoteData<Item>) => itemRD.payload.owningCollection)
|
||||
);
|
||||
const itemCollectionsAndOptions$ = observableCombineLatest(
|
||||
this.itemCollectionsRD$,
|
||||
owningCollectionRD$,
|
||||
this.searchOptions$
|
||||
);
|
||||
this.mappedCollectionsRD$ = itemCollectionsAndOptions$.pipe(
|
||||
switchMap(([itemCollectionsRD, owningCollectionRD, searchOptions]) => {
|
||||
return this.searchService.search(Object.assign(new PaginatedSearchOptions(searchOptions), {
|
||||
query: this.buildQuery([...itemCollectionsRD.payload.page, owningCollectionRD.payload], searchOptions.query),
|
||||
dsoType: DSpaceObjectType.COLLECTION
|
||||
}), 10000).pipe(
|
||||
toDSpaceObjectListRD(),
|
||||
startWith(undefined)
|
||||
);
|
||||
})
|
||||
) as Observable<RemoteData<PaginatedList<Collection>>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map the item to the selected collections and display notifications
|
||||
* @param {string[]} ids The list of collection UUID's to map the item to
|
||||
*/
|
||||
mapCollections(ids: string[]) {
|
||||
const itemIdAndExcludingIds$ = observableCombineLatest(
|
||||
this.itemRD$.pipe(
|
||||
getSucceededRemoteData(),
|
||||
take(1),
|
||||
map((rd: RemoteData<Item>) => rd.payload),
|
||||
map((item: Item) => item.id)
|
||||
),
|
||||
this.itemCollectionsRD$.pipe(
|
||||
getSucceededRemoteData(),
|
||||
take(1),
|
||||
map((rd: RemoteData<PaginatedList<Collection>>) => rd.payload.page),
|
||||
map((collections: Collection[]) => collections.map((collection: Collection) => collection.id))
|
||||
)
|
||||
);
|
||||
|
||||
// Map the item to the collections found in ids, excluding the collections the item is already mapped to
|
||||
const responses$ = itemIdAndExcludingIds$.pipe(
|
||||
switchMap(([itemId, excludingIds]) => observableCombineLatest(this.filterIds(ids, excludingIds).map((id: string) => this.itemDataService.mapToCollection(itemId, id))))
|
||||
);
|
||||
|
||||
this.showNotifications(responses$, 'item.edit.item-mapper.notifications.add');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the mapping of the item to the selected collections and display notifications
|
||||
* @param {string[]} ids The list of collection UUID's to remove the mapping of the item for
|
||||
*/
|
||||
removeMappings(ids: string[]) {
|
||||
const responses$ = this.itemRD$.pipe(
|
||||
getSucceededRemoteData(),
|
||||
map((itemRD: RemoteData<Item>) => itemRD.payload.id),
|
||||
switchMap((itemId: string) => observableCombineLatest(ids.map((id: string) => this.itemDataService.removeMappingFromCollection(itemId, id))))
|
||||
);
|
||||
|
||||
this.showNotifications(responses$, 'item.edit.item-mapper.notifications.remove');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters ids from a given list of ids, which exist in a second given list of ids
|
||||
* @param {string[]} ids The list of ids to filter out of
|
||||
* @param {string[]} excluding The ids that should be excluded from the first list
|
||||
* @returns {string[]}
|
||||
*/
|
||||
private filterIds(ids: string[], excluding: string[]): string[] {
|
||||
return ids.filter((id: string) => excluding.indexOf(id) < 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display notifications
|
||||
* @param {Observable<RestResponse[]>} responses$ The responses after adding/removing a mapping
|
||||
* @param {string} messagePrefix The prefix to build the notification messages with
|
||||
*/
|
||||
private showNotifications(responses$: Observable<RestResponse[]>, messagePrefix: string) {
|
||||
responses$.subscribe((responses: RestResponse[]) => {
|
||||
const successful = responses.filter((response: RestResponse) => response.isSuccessful);
|
||||
const unsuccessful = responses.filter((response: RestResponse) => !response.isSuccessful);
|
||||
if (successful.length > 0) {
|
||||
const successMessages = observableCombineLatest(
|
||||
this.translateService.get(`${messagePrefix}.success.head`),
|
||||
this.translateService.get(`${messagePrefix}.success.content`, { amount: successful.length })
|
||||
);
|
||||
|
||||
successMessages.subscribe(([head, content]) => {
|
||||
this.notificationsService.success(head, content);
|
||||
});
|
||||
}
|
||||
if (unsuccessful.length > 0) {
|
||||
const unsuccessMessages = observableCombineLatest(
|
||||
this.translateService.get(`${messagePrefix}.error.head`),
|
||||
this.translateService.get(`${messagePrefix}.error.content`, { amount: unsuccessful.length })
|
||||
);
|
||||
|
||||
unsuccessMessages.subscribe(([head, content]) => {
|
||||
this.notificationsService.error(head, content);
|
||||
});
|
||||
}
|
||||
// Force an update on all lists and switch back to the first tab
|
||||
this.shouldUpdate$.next(true);
|
||||
this.switchToFirstTab();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear url parameters on tab change (temporary fix until pagination is improved)
|
||||
* @param event
|
||||
*/
|
||||
tabChange(event) {
|
||||
this.performedSearch = false;
|
||||
this.router.navigateByUrl(this.getCurrentUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current url without parameters
|
||||
* @returns {string}
|
||||
*/
|
||||
getCurrentUrl(): string {
|
||||
if (this.router.url.indexOf('?') > -1) {
|
||||
return this.router.url.substring(0, this.router.url.indexOf('?'));
|
||||
}
|
||||
return this.router.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a query to exclude collections from
|
||||
* @param collections The collections their UUIDs
|
||||
* @param query The query to add to it
|
||||
*/
|
||||
buildQuery(collections: Collection[], query: string): string {
|
||||
let result = query;
|
||||
for (const collection of collections) {
|
||||
result = this.addExcludeCollection(collection.id, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an exclusion of a collection to a query
|
||||
* @param collectionId The collection's UUID
|
||||
* @param query The query to add the exclusion to
|
||||
*/
|
||||
addExcludeCollection(collectionId: string, query: string): string {
|
||||
const excludeQuery = `-search.resourceid:${collectionId}`;
|
||||
if (isNotEmpty(query)) {
|
||||
return `${query} AND ${excludeQuery}`;
|
||||
} else {
|
||||
return excludeQuery;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the view to focus on the first tab
|
||||
*/
|
||||
switchToFirstTab() {
|
||||
this.tabs.select('browseTab');
|
||||
}
|
||||
|
||||
/**
|
||||
* When a cancel event is fired, return to the item page
|
||||
*/
|
||||
onCancel() {
|
||||
this.itemRD$.pipe(
|
||||
getSucceededRemoteData(),
|
||||
getRemoteDataPayload(),
|
||||
take(1)
|
||||
).subscribe((item: Item) => {
|
||||
this.router.navigate(['/items/', item.id])
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -4,7 +4,7 @@
|
||||
<span>{{metadata?.key?.split('.').join('.​')}}</span>
|
||||
</div>
|
||||
<div *ngIf="(editable | async)" class="field-container">
|
||||
<ds-input-suggestions [suggestions]="(metadataFieldSuggestions | async)"
|
||||
<ds-filter-input-suggestions [suggestions]="(metadataFieldSuggestions | async)"
|
||||
[(ngModel)]="metadata.key"
|
||||
(submitSuggestion)="update(suggestionControl)"
|
||||
(clickSuggestion)="update(suggestionControl)"
|
||||
@@ -16,7 +16,7 @@
|
||||
[valid]="(valid | async) !== false"
|
||||
dsAutoFocus autoFocusSelector=".suggestion_input"
|
||||
[ngModelOptions]="{standalone: true}"
|
||||
></ds-input-suggestions>
|
||||
></ds-filter-input-suggestions>
|
||||
</div>
|
||||
<small class="text-danger"
|
||||
*ngIf="(valid | async) === false">{{"item.edit.metadata.metadatafield.invalid" | translate}}</small>
|
||||
|
@@ -10,7 +10,6 @@ import { By } from '@angular/platform-browser';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { SharedModule } from '../../../../shared/shared.module';
|
||||
import { getTestScheduler } from 'jasmine-marbles';
|
||||
import { InputSuggestion } from '../../../../shared/input-suggestions/input-suggestions.model';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import { FieldChangeType } from '../../../../core/data/object-updates/object-updates.actions';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -18,6 +17,7 @@ import { MetadatumViewModel } from '../../../../core/shared/metadata.models';
|
||||
import { MetadataSchema } from '../../../../core/metadata/metadata-schema.model';
|
||||
import { MetadataField } from '../../../../core/metadata/metadata-field.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
import { InputSuggestion } from '../../../../shared/input-suggestions/input-suggestions.model';
|
||||
|
||||
let comp: EditInPlaceFieldComponent;
|
||||
let fixture: ComponentFixture<EditInPlaceFieldComponent>;
|
||||
|
@@ -4,13 +4,13 @@ import { RegistryService } from '../../../../core/registry/registry.service';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { BehaviorSubject, Observable, of as observableOf } from 'rxjs';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import { InputSuggestion } from '../../../../shared/input-suggestions/input-suggestions.model';
|
||||
import { FieldChangeType } from '../../../../core/data/object-updates/object-updates.actions';
|
||||
import { FieldUpdate } from '../../../../core/data/object-updates/object-updates.reducer';
|
||||
import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service';
|
||||
import { NgModel } from '@angular/forms';
|
||||
import { MetadatumViewModel } from '../../../../core/shared/metadata.models';
|
||||
import { MetadataField } from '../../../../core/metadata/metadata-field.model';
|
||||
import { InputSuggestion } from '../../../../shared/input-suggestions/input-suggestions.model';
|
||||
|
||||
@Component({
|
||||
// tslint:disable-next-line:component-selector
|
||||
|
@@ -31,7 +31,7 @@ import {
|
||||
createSuccessfulRemoteDataObject$
|
||||
} from '../../../shared/testing/utils';
|
||||
|
||||
let comp: ItemMetadataComponent;
|
||||
let comp: any;
|
||||
let fixture: ComponentFixture<ItemMetadataComponent>;
|
||||
let de: DebugElement;
|
||||
let el: HTMLElement;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Component, Inject, Input, OnInit } from '@angular/core';
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { ObjectUpdatesService } from '../../../core/data/object-updates/object-updates.service';
|
||||
@@ -6,8 +6,6 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { Observable } from 'rxjs';
|
||||
import {
|
||||
FieldUpdate,
|
||||
FieldUpdates,
|
||||
Identifiable
|
||||
} from '../../../core/data/object-updates/object-updates.reducer';
|
||||
import { first, map, switchMap, take, tap } from 'rxjs/operators';
|
||||
@@ -19,6 +17,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
import { RegistryService } from '../../../core/registry/registry.service';
|
||||
import { MetadatumViewModel } from '../../../core/shared/metadata.models';
|
||||
import { Metadata } from '../../../core/shared/metadata.utils';
|
||||
import { AbstractItemUpdateComponent } from '../abstract-item-update/abstract-item-update.component';
|
||||
import { MetadataField } from '../../../core/metadata/metadata-field.model';
|
||||
|
||||
@Component({
|
||||
@@ -29,28 +28,7 @@ import { MetadataField } from '../../../core/metadata/metadata-field.model';
|
||||
/**
|
||||
* Component for displaying an item's metadata edit page
|
||||
*/
|
||||
export class ItemMetadataComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* The item to display the edit page for
|
||||
*/
|
||||
item: Item;
|
||||
/**
|
||||
* The current values and updates for all this item's metadata fields
|
||||
*/
|
||||
updates$: Observable<FieldUpdates>;
|
||||
/**
|
||||
* The current url of this page
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* The time span for being able to undo discarding changes
|
||||
*/
|
||||
private discardTimeOut: number;
|
||||
/**
|
||||
* Prefix for this component's notification translate keys
|
||||
*/
|
||||
private notificationsPrefix = 'item.edit.metadata.notifications.';
|
||||
export class ItemMetadataComponent extends AbstractItemUpdateComponent {
|
||||
|
||||
/**
|
||||
* Observable with a list of strings with all existing metadata field keys
|
||||
@@ -58,44 +36,38 @@ export class ItemMetadataComponent implements OnInit {
|
||||
metadataFields$: Observable<string[]>;
|
||||
|
||||
constructor(
|
||||
private itemService: ItemDataService,
|
||||
private objectUpdatesService: ObjectUpdatesService,
|
||||
private router: Router,
|
||||
private notificationsService: NotificationsService,
|
||||
private translateService: TranslateService,
|
||||
protected itemService: ItemDataService,
|
||||
protected objectUpdatesService: ObjectUpdatesService,
|
||||
protected router: Router,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected translateService: TranslateService,
|
||||
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||
private route: ActivatedRoute,
|
||||
private metadataFieldService: RegistryService,
|
||||
protected route: ActivatedRoute,
|
||||
protected metadataFieldService: RegistryService,
|
||||
) {
|
||||
|
||||
super(itemService, objectUpdatesService, router, notificationsService, translateService, EnvConfig, route);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up and initialize all fields
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
super.ngOnInit();
|
||||
this.metadataFields$ = this.findMetadataFields();
|
||||
this.route.parent.data.pipe(map((data) => data.item))
|
||||
.pipe(
|
||||
first(),
|
||||
map((data: RemoteData<Item>) => data.payload)
|
||||
).subscribe((item: Item) => {
|
||||
this.item = item;
|
||||
});
|
||||
}
|
||||
|
||||
this.discardTimeOut = this.EnvConfig.item.edit.undoTimeout;
|
||||
this.url = this.router.url;
|
||||
if (this.url.indexOf('?') > 0) {
|
||||
this.url = this.url.substr(0, this.url.indexOf('?'));
|
||||
}
|
||||
this.hasChanges().pipe(first()).subscribe((hasChanges) => {
|
||||
if (!hasChanges) {
|
||||
this.initializeOriginalFields();
|
||||
} else {
|
||||
this.checkLastModified();
|
||||
}
|
||||
});
|
||||
this.updates$ = this.objectUpdatesService.getFieldUpdates(this.url, this.item.metadataAsList);
|
||||
/**
|
||||
* Initialize the values and updates of the current item's metadata fields
|
||||
*/
|
||||
public initializeUpdates(): void {
|
||||
this.updates$ = this.objectUpdatesService.getFieldUpdates(this.url, this.getMetadataAsListExcludingRelationships());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the prefix for notification messages
|
||||
*/
|
||||
public initializeNotificationsPrefix(): void {
|
||||
this.notificationsPrefix = 'item.edit.metadata.notifications.';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,47 +76,23 @@ export class ItemMetadataComponent implements OnInit {
|
||||
*/
|
||||
add(metadata: MetadatumViewModel = new MetadatumViewModel()) {
|
||||
this.objectUpdatesService.saveAddFieldUpdate(this.url, metadata);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the object updates service to discard all current changes to this item
|
||||
* Shows a notification to remind the user that they can undo this
|
||||
*/
|
||||
discard() {
|
||||
const undoNotification = this.notificationsService.info(this.getNotificationTitle('discarded'), this.getNotificationContent('discarded'), { timeOut: this.discardTimeOut });
|
||||
this.objectUpdatesService.discardFieldUpdates(this.url, undoNotification);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the object updates service to undo discarding all changes to this item
|
||||
*/
|
||||
reinstate() {
|
||||
this.objectUpdatesService.reinstateFieldUpdates(this.url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends all initial values of this item to the object updates service
|
||||
*/
|
||||
private initializeOriginalFields() {
|
||||
this.objectUpdatesService.initialize(this.url, this.item.metadataAsList, this.item.lastModified);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent unnecessary rerendering so fields don't lose focus
|
||||
*/
|
||||
trackUpdate(index, update: FieldUpdate) {
|
||||
return update && update.field ? update.field.uuid : undefined;
|
||||
public initializeOriginalFields() {
|
||||
this.objectUpdatesService.initialize(this.url, this.getMetadataAsListExcludingRelationships(), this.item.lastModified);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests all current metadata for this item and requests the item service to update the item
|
||||
* Makes sure the new version of the item is rendered on the page
|
||||
*/
|
||||
submit() {
|
||||
public submit() {
|
||||
this.isValid().pipe(first()).subscribe((isValid) => {
|
||||
if (isValid) {
|
||||
const metadata$: Observable<Identifiable[]> = this.objectUpdatesService.getUpdatedFields(this.url, this.item.metadataAsList) as Observable<MetadatumViewModel[]>;
|
||||
const metadata$: Observable<Identifiable[]> = this.objectUpdatesService.getUpdatedFields(this.url, this.getMetadataAsListExcludingRelationships()) as Observable<MetadatumViewModel[]>;
|
||||
metadata$.pipe(
|
||||
first(),
|
||||
switchMap((metadata: MetadatumViewModel[]) => {
|
||||
@@ -157,7 +105,7 @@ export class ItemMetadataComponent implements OnInit {
|
||||
(rd: RemoteData<Item>) => {
|
||||
this.item = rd.payload;
|
||||
this.initializeOriginalFields();
|
||||
this.updates$ = this.objectUpdatesService.getFieldUpdates(this.url, this.item.metadataAsList);
|
||||
this.updates$ = this.objectUpdatesService.getFieldUpdates(this.url, this.getMetadataAsListExcludingRelationships());
|
||||
this.notificationsService.success(this.getNotificationTitle('saved'), this.getNotificationContent('saved'));
|
||||
}
|
||||
)
|
||||
@@ -167,60 +115,6 @@ export class ItemMetadataComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not there are currently updates for this item
|
||||
*/
|
||||
hasChanges(): Observable<boolean> {
|
||||
return this.objectUpdatesService.hasUpdates(this.url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not the item is currently reinstatable
|
||||
*/
|
||||
isReinstatable(): Observable<boolean> {
|
||||
return this.objectUpdatesService.isReinstatable(this.url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current item is still in sync with the version in the store
|
||||
* If it's not, a notification is shown and the changes are removed
|
||||
*/
|
||||
private checkLastModified() {
|
||||
const currentVersion = this.item.lastModified;
|
||||
this.objectUpdatesService.getLastModified(this.url).pipe(first()).subscribe(
|
||||
(updateVersion: Date) => {
|
||||
if (updateVersion.getDate() !== currentVersion.getDate()) {
|
||||
this.notificationsService.warning(this.getNotificationTitle('outdated'), this.getNotificationContent('outdated'));
|
||||
this.initializeOriginalFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current page is entirely valid
|
||||
*/
|
||||
private isValid() {
|
||||
return this.objectUpdatesService.isValidPage(this.url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translated notification title
|
||||
* @param key
|
||||
*/
|
||||
private getNotificationTitle(key: string) {
|
||||
return this.translateService.instant(this.notificationsPrefix + key + '.title');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translated notification content
|
||||
* @param key
|
||||
*/
|
||||
private getNotificationContent(key: string) {
|
||||
return this.translateService.instant(this.notificationsPrefix + key + '.content');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to request all metadata fields and convert them to a list of strings
|
||||
*/
|
||||
@@ -230,4 +124,8 @@ export class ItemMetadataComponent implements OnInit {
|
||||
take(1),
|
||||
map((remoteData$) => remoteData$.payload.page.map((field: MetadataField) => field.toString())));
|
||||
}
|
||||
|
||||
getMetadataAsListExcludingRelationships(): MetadatumViewModel[] {
|
||||
return this.item.metadataAsList.filter((metadata: MetadatumViewModel) => !metadata.key.startsWith('relation.') && !metadata.key.startsWith('relationship.'));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,48 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h2>{{'item.edit.move.head' | translate: {id: (itemRD$ | async)?.payload?.handle} }}</h2>
|
||||
<p>{{'item.edit.move.description' | translate}}</p>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<ds-dso-input-suggestions #f id="search-form"
|
||||
[suggestions]="(collectionSearchResults | async)"
|
||||
[placeholder]="'item.edit.move.search.placeholder'| translate"
|
||||
[action]="getCurrentUrl()"
|
||||
[name]="'item-move'"
|
||||
[(ngModel)]="selectedCollectionName"
|
||||
(clickSuggestion)="onClick($event)"
|
||||
(typeSuggestion)="resetCollection($event)"
|
||||
(findSuggestions)="findSuggestions($event)"
|
||||
(click)="f.open()"
|
||||
ngDefaultControl>
|
||||
</ds-dso-input-suggestions>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<p>
|
||||
<input type="checkbox" name="tc" [(ngModel)]="inheritPolicies" id="inheritPoliciesCheckbox">
|
||||
<label for="inheritPoliciesCheckbox">{{'item.edit.move.inheritpolicies.checkbox' |
|
||||
translate}}</label>
|
||||
</p>
|
||||
<p>
|
||||
{{'item.edit.move.inheritpolicies.description' | translate}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button (click)="moveCollection()" class="btn btn-primary" [disabled]=!canSubmit>
|
||||
<span *ngIf="!processing"> {{'item.edit.move.move' | translate}}</span>
|
||||
<span *ngIf="processing"><i class='fas fa-circle-notch fa-spin'></i>
|
||||
{{'item.edit.move.processing' | translate}}
|
||||
</span>
|
||||
</button>
|
||||
<button [routerLink]="['/items/', (itemRD$ | async)?.payload?.id, 'edit']"
|
||||
class="btn btn-outline-secondary">
|
||||
{{'item.edit.move.cancel' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,172 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { RouterStub } from '../../../shared/testing/router-stub';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ItemMoveComponent } from './item-move.component';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service-stub';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { SearchService } from '../../../+search-page/search-service/search.service';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { RestResponse } from '../../../core/cache/response.models';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
|
||||
describe('ItemMoveComponent', () => {
|
||||
let comp: ItemMoveComponent;
|
||||
let fixture: ComponentFixture<ItemMoveComponent>;
|
||||
|
||||
const mockItem = Object.assign(new Item(), {
|
||||
id: 'fake-id',
|
||||
handle: 'fake/handle',
|
||||
lastModified: '2018'
|
||||
});
|
||||
|
||||
const itemPageUrl = `fake-url/${mockItem.id}`;
|
||||
const routerStub = Object.assign(new RouterStub(), {
|
||||
url: `${itemPageUrl}/edit`
|
||||
});
|
||||
|
||||
const mockItemDataService = jasmine.createSpyObj({
|
||||
moveToCollection: observableOf(new RestResponse(true, 200, 'Success'))
|
||||
});
|
||||
|
||||
const mockItemDataServiceFail = jasmine.createSpyObj({
|
||||
moveToCollection: observableOf(new RestResponse(false, 500, 'Internal server error'))
|
||||
});
|
||||
|
||||
const routeStub = {
|
||||
data: observableOf({
|
||||
item: new RemoteData(false, false, true, null, {
|
||||
id: 'item1'
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
const collection1 = Object.assign(new Collection(),{
|
||||
uuid: 'collection-uuid-1',
|
||||
name: 'Test collection 1',
|
||||
self: 'self-link-1',
|
||||
});
|
||||
|
||||
const collection2 = Object.assign(new Collection(),{
|
||||
uuid: 'collection-uuid-2',
|
||||
name: 'Test collection 2',
|
||||
self: 'self-link-2',
|
||||
});
|
||||
|
||||
const mockSearchService = {
|
||||
search: () => {
|
||||
return observableOf(new RemoteData(false, false, true, null,
|
||||
new PaginatedList(null, [
|
||||
{
|
||||
indexableObject: collection1,
|
||||
hitHighlights: {}
|
||||
}, {
|
||||
indexableObject: collection2,
|
||||
hitHighlights: {}
|
||||
}
|
||||
])));
|
||||
}
|
||||
};
|
||||
|
||||
const notificationsServiceStub = new NotificationsServiceStub();
|
||||
|
||||
describe('ItemMoveComponent success', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [ItemMoveComponent],
|
||||
providers: [
|
||||
{provide: ActivatedRoute, useValue: routeStub},
|
||||
{provide: Router, useValue: routerStub},
|
||||
{provide: ItemDataService, useValue: mockItemDataService},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||
{provide: SearchService, useValue: mockSearchService},
|
||||
], schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ItemMoveComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
it('should load suggestions', () => {
|
||||
const expected = [
|
||||
collection1,
|
||||
collection2
|
||||
];
|
||||
|
||||
comp.collectionSearchResults.subscribe((value) => {
|
||||
expect(value).toEqual(expected);
|
||||
}
|
||||
);
|
||||
});
|
||||
it('should get current url ', () => {
|
||||
expect(comp.getCurrentUrl()).toEqual('fake-url/fake-id/edit');
|
||||
});
|
||||
it('should on click select the correct collection name and id', () => {
|
||||
const data = collection1;
|
||||
|
||||
comp.onClick(data);
|
||||
|
||||
expect(comp.selectedCollectionName).toEqual('Test collection 1');
|
||||
expect(comp.selectedCollection).toEqual(collection1);
|
||||
});
|
||||
describe('moveCollection', () => {
|
||||
it('should call itemDataService.moveToCollection', () => {
|
||||
comp.itemId = 'item-id';
|
||||
comp.selectedCollectionName = 'selected-collection-id';
|
||||
comp.selectedCollection = collection1;
|
||||
comp.moveCollection();
|
||||
|
||||
expect(mockItemDataService.moveToCollection).toHaveBeenCalledWith('item-id', collection1);
|
||||
});
|
||||
it('should call notificationsService success message on success', () => {
|
||||
comp.moveCollection();
|
||||
|
||||
expect(notificationsServiceStub.success).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ItemMoveComponent fail', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [ItemMoveComponent],
|
||||
providers: [
|
||||
{provide: ActivatedRoute, useValue: routeStub},
|
||||
{provide: Router, useValue: routerStub},
|
||||
{provide: ItemDataService, useValue: mockItemDataServiceFail},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||
{provide: SearchService, useValue: mockSearchService},
|
||||
], schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ItemMoveComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call notificationsService error message on fail', () => {
|
||||
comp.moveCollection();
|
||||
|
||||
expect(notificationsServiceStub.error).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,139 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { SearchService } from '../../../+search-page/search-service/search.service';
|
||||
import { first, map } from 'rxjs/operators';
|
||||
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||
import { SearchOptions } from '../../../+search-page/search-options.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { SearchResult } from '../../../+search-page/search-result.model';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { getSucceededRemoteData } from '../../../core/shared/operators';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { getItemEditPath } from '../../item-page-routing.module';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { RestResponse } from '../../../core/cache/response.models';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { tap } from 'rxjs/internal/operators/tap';
|
||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||
import { PaginatedSearchOptions } from '../../../+search-page/paginated-search-options.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-move',
|
||||
templateUrl: './item-move.component.html'
|
||||
})
|
||||
/**
|
||||
* Component that handles the moving of an item to a different collection
|
||||
*/
|
||||
export class ItemMoveComponent implements OnInit {
|
||||
/**
|
||||
* TODO: There is currently no backend support to change the owningCollection and inherit policies,
|
||||
* TODO: when this is added, the inherit policies option should be used.
|
||||
*/
|
||||
|
||||
selectorType = DSpaceObjectType.COLLECTION;
|
||||
|
||||
inheritPolicies = false;
|
||||
itemRD$: Observable<RemoteData<Item>>;
|
||||
collectionSearchResults: Observable<any[]> = observableOf([]);
|
||||
selectedCollectionName: string;
|
||||
selectedCollection: Collection;
|
||||
canSubmit = false;
|
||||
|
||||
itemId: string;
|
||||
processing = false;
|
||||
|
||||
pagination = new PaginationComponentOptions();
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private notificationsService: NotificationsService,
|
||||
private itemDataService: ItemDataService,
|
||||
private searchService: SearchService,
|
||||
private translateService: TranslateService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.itemRD$ = this.route.data.pipe(map((data) => data.item), getSucceededRemoteData()) as Observable<RemoteData<Item>>;
|
||||
this.itemRD$.subscribe((rd) => {
|
||||
this.itemId = rd.payload.id;
|
||||
}
|
||||
);
|
||||
this.pagination.pageSize = 5;
|
||||
this.loadSuggestions('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Find suggestions based on entered query
|
||||
* @param query - Search query
|
||||
*/
|
||||
findSuggestions(query): void {
|
||||
this.loadSuggestions(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all available collections to move the item to.
|
||||
* TODO: When the API support it, only fetch collections where user has ADD rights to.
|
||||
*/
|
||||
loadSuggestions(query): void {
|
||||
this.collectionSearchResults = this.searchService.search(new PaginatedSearchOptions({
|
||||
pagination: this.pagination,
|
||||
dsoType: DSpaceObjectType.COLLECTION,
|
||||
query: query
|
||||
})).pipe(
|
||||
first(),
|
||||
map((rd: RemoteData<PaginatedList<SearchResult<DSpaceObject>>>) => {
|
||||
return rd.payload.page.map((searchResult) => {
|
||||
return searchResult.indexableObject
|
||||
})
|
||||
}) ,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the collection name and id based on the selected value
|
||||
* @param data - obtained from the ds-input-suggestions component
|
||||
*/
|
||||
onClick(data: any): void {
|
||||
this.selectedCollection = data;
|
||||
this.selectedCollectionName = data.name;
|
||||
this.canSubmit = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} the current URL
|
||||
*/
|
||||
getCurrentUrl() {
|
||||
return this.router.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the item to a new collection based on the selected collection
|
||||
*/
|
||||
moveCollection() {
|
||||
this.processing = true;
|
||||
this.itemDataService.moveToCollection(this.itemId, this.selectedCollection).pipe(first()).subscribe(
|
||||
(response: RestResponse) => {
|
||||
this.router.navigate([getItemEditPath(this.itemId)]);
|
||||
if (response.isSuccessful) {
|
||||
this.notificationsService.success(this.translateService.get('item.edit.move.success'));
|
||||
} else {
|
||||
this.notificationsService.error(this.translateService.get('item.edit.move.error'));
|
||||
}
|
||||
this.processing = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the can submit when the user changes the content of the input field
|
||||
* @param data
|
||||
*/
|
||||
resetCollection(data: any) {
|
||||
this.canSubmit = false;
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@
|
||||
</span>
|
||||
</div>
|
||||
<div *ngIf="!operation.disabled" class="col-9 float-left action-button">
|
||||
<a class="btn btn-outline-secondary" href="{{operation.operationUrl}}">
|
||||
<a class="btn btn-outline-secondary" [routerLink]="operation.operationUrl">
|
||||
{{'item.edit.tabs.status.buttons.' + operation.operationKey + '.button' | translate}}
|
||||
</a>
|
||||
</div>
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import {ItemOperation} from './itemOperation.model';
|
||||
import {async, TestBed} from '@angular/core/testing';
|
||||
import {ItemOperationComponent} from './item-operation.component';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {By} from '@angular/platform-browser';
|
||||
import { ItemOperation } from './itemOperation.model';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { ItemOperationComponent } from './item-operation.component';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
describe('ItemOperationComponent', () => {
|
||||
let itemOperation: ItemOperation;
|
||||
@@ -12,7 +13,7 @@ describe('ItemOperationComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot()],
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])],
|
||||
declarations: [ItemOperationComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
@@ -0,0 +1,15 @@
|
||||
<ng-container *ngVar="(updates$ | async) as updates">
|
||||
<div *ngIf="updates">
|
||||
<h5>{{getRelationshipMessageKey(relationshipLabel) | translate}}</h5>
|
||||
<ng-container *ngVar="(updates | dsObjectValues) as updateValues">
|
||||
<div *ngFor="let updateValue of updateValues; trackBy: trackUpdate"
|
||||
ds-edit-relationship
|
||||
class="relationship-row d-block"
|
||||
[fieldUpdate]="updateValue || {}"
|
||||
[url]="url"
|
||||
[ngClass]="{'alert alert-danger': updateValue.changeType === 2}">
|
||||
</div>
|
||||
<ds-loading *ngIf="updateValues.length == 0" message="{{'loading.items' | translate}}"></ds-loading>
|
||||
</ng-container>
|
||||
</div>
|
||||
</ng-container>
|
@@ -0,0 +1,12 @@
|
||||
@import '../../../../../styles/variables.scss';
|
||||
|
||||
.relationship-row:not(.alert-danger) {
|
||||
padding: $alert-padding-y 0;
|
||||
}
|
||||
|
||||
.relationship-row.alert-danger {
|
||||
margin-left: -$alert-padding-x;
|
||||
margin-right: -$alert-padding-x;
|
||||
margin-top: -1px;
|
||||
margin-bottom: -1px;
|
||||
}
|
@@ -0,0 +1,136 @@
|
||||
import { EditRelationshipListComponent } from './edit-relationship-list.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { ResourceType } from '../../../../core/shared/resource-type';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { FieldChangeType } from '../../../../core/data/object-updates/object-updates.actions';
|
||||
import { SharedModule } from '../../../../shared/shared.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service';
|
||||
import { RelationshipService } from '../../../../core/data/relationship.service';
|
||||
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
let comp: EditRelationshipListComponent;
|
||||
let fixture: ComponentFixture<EditRelationshipListComponent>;
|
||||
let de: DebugElement;
|
||||
|
||||
let objectUpdatesService;
|
||||
let relationshipService;
|
||||
|
||||
const url = 'http://test-url.com/test-url';
|
||||
|
||||
let item;
|
||||
let author1;
|
||||
let author2;
|
||||
let fieldUpdate1;
|
||||
let fieldUpdate2;
|
||||
let relationships;
|
||||
let relationshipType;
|
||||
|
||||
describe('EditRelationshipListComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
relationshipType = Object.assign(new RelationshipType(), {
|
||||
id: '1',
|
||||
uuid: '1',
|
||||
leftwardType: 'isAuthorOfPublication',
|
||||
rightwardType: 'isPublicationOfAuthor'
|
||||
});
|
||||
|
||||
relationships = [
|
||||
Object.assign(new Relationship(), {
|
||||
self: url + '/2',
|
||||
id: '2',
|
||||
uuid: '2',
|
||||
leftId: 'author1',
|
||||
rightId: 'publication',
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType))
|
||||
}),
|
||||
Object.assign(new Relationship(), {
|
||||
self: url + '/3',
|
||||
id: '3',
|
||||
uuid: '3',
|
||||
leftId: 'author2',
|
||||
rightId: 'publication',
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType))
|
||||
})
|
||||
];
|
||||
|
||||
item = Object.assign(new Item(), {
|
||||
self: 'fake-item-url/publication',
|
||||
id: 'publication',
|
||||
uuid: 'publication',
|
||||
relationships: observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(new PageInfo(), relationships)))
|
||||
});
|
||||
|
||||
author1 = Object.assign(new Item(), {
|
||||
id: 'author1',
|
||||
uuid: 'author1'
|
||||
});
|
||||
author2 = Object.assign(new Item(), {
|
||||
id: 'author2',
|
||||
uuid: 'author2'
|
||||
});
|
||||
|
||||
fieldUpdate1 = {
|
||||
field: author1,
|
||||
changeType: undefined
|
||||
};
|
||||
fieldUpdate2 = {
|
||||
field: author2,
|
||||
changeType: FieldChangeType.REMOVE
|
||||
};
|
||||
|
||||
objectUpdatesService = jasmine.createSpyObj('objectUpdatesService',
|
||||
{
|
||||
getFieldUpdatesExclusive: observableOf({
|
||||
[author1.uuid]: fieldUpdate1,
|
||||
[author2.uuid]: fieldUpdate2
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
relationshipService = jasmine.createSpyObj('relationshipService',
|
||||
{
|
||||
getRelatedItemsByLabel: observableOf([author1, author2]),
|
||||
}
|
||||
);
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [SharedModule, TranslateModule.forRoot()],
|
||||
declarations: [EditRelationshipListComponent],
|
||||
providers: [
|
||||
{ provide: ObjectUpdatesService, useValue: objectUpdatesService },
|
||||
{ provide: RelationshipService, useValue: relationshipService }
|
||||
], schemas: [
|
||||
NO_ERRORS_SCHEMA
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EditRelationshipListComponent);
|
||||
comp = fixture.componentInstance;
|
||||
de = fixture.debugElement;
|
||||
comp.item = item;
|
||||
comp.url = url;
|
||||
comp.relationshipLabel = relationshipType.leftwardType;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('changeType is REMOVE', () => {
|
||||
beforeEach(() => {
|
||||
fieldUpdate1.changeType = FieldChangeType.REMOVE;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
it('the div should have class alert-danger', () => {
|
||||
const element = de.queryAll(By.css('.relationship-row'))[1].nativeElement;
|
||||
expect(element.classList).toContain('alert-danger');
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,99 @@
|
||||
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
|
||||
import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { FieldUpdate, FieldUpdates } from '../../../../core/data/object-updates/object-updates.reducer';
|
||||
import { RelationshipService } from '../../../../core/data/relationship.service';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { hasValue } from '../../../../shared/empty.util';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-edit-relationship-list',
|
||||
styleUrls: ['./edit-relationship-list.component.scss'],
|
||||
templateUrl: './edit-relationship-list.component.html',
|
||||
})
|
||||
/**
|
||||
* A component creating a list of editable relationships of a certain type
|
||||
* The relationships are rendered as a list of related items
|
||||
*/
|
||||
export class EditRelationshipListComponent implements OnInit, OnChanges {
|
||||
/**
|
||||
* The item to display related items for
|
||||
*/
|
||||
@Input() item: Item;
|
||||
|
||||
/**
|
||||
* The URL to the current page
|
||||
* Used to fetch updates for the current item from the store
|
||||
*/
|
||||
@Input() url: string;
|
||||
|
||||
/**
|
||||
* The label of the relationship-type we're rendering a list for
|
||||
*/
|
||||
@Input() relationshipLabel: string;
|
||||
|
||||
/**
|
||||
* The FieldUpdates for the relationships in question
|
||||
*/
|
||||
updates$: Observable<FieldUpdates>;
|
||||
|
||||
constructor(
|
||||
protected objectUpdatesService: ObjectUpdatesService,
|
||||
protected relationshipService: RelationshipService
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.initUpdates();
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
this.initUpdates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the FieldUpdates using the related items
|
||||
*/
|
||||
initUpdates() {
|
||||
this.updates$ = this.getUpdatesByLabel(this.relationshipLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the item's relationships of a specific type into related items
|
||||
* @param label The relationship type's label
|
||||
*/
|
||||
public getRelatedItemsByLabel(label: string): Observable<Item[]> {
|
||||
return this.relationshipService.getRelatedItemsByLabel(this.item, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get FieldUpdates for the relationships of a specific type
|
||||
* @param label The relationship type's label
|
||||
*/
|
||||
public getUpdatesByLabel(label: string): Observable<FieldUpdates> {
|
||||
return this.getRelatedItemsByLabel(label).pipe(
|
||||
switchMap((items: Item[]) => this.objectUpdatesService.getFieldUpdatesExclusive(this.url, items))
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the i18n message key for a relationship
|
||||
* @param label The relationship type's label
|
||||
*/
|
||||
public getRelationshipMessageKey(label: string): string {
|
||||
if (hasValue(label) && label.indexOf('Of') > -1) {
|
||||
return `relationships.${label.substring(0, label.indexOf('Of') + 2)}`
|
||||
} else {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent unnecessary rerendering so fields don't lose focus
|
||||
*/
|
||||
trackUpdate(index, update: FieldUpdate) {
|
||||
return update && update.field ? update.field.uuid : undefined;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
<div class="row" *ngIf="item">
|
||||
<div class="col-10 relationship">
|
||||
<ds-item-type-switcher [object]="item" [viewMode]="viewMode"></ds-item-type-switcher>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="btn-group relationship-action-buttons">
|
||||
<button [disabled]="!canRemove()" (click)="remove()"
|
||||
class="btn btn-outline-danger btn-sm"
|
||||
title="{{'item.edit.metadata.edit.buttons.remove' | translate}}">
|
||||
<i class="fas fa-trash-alt fa-fw"></i>
|
||||
</button>
|
||||
<button [disabled]="!canUndo()" (click)="undo()"
|
||||
class="btn btn-outline-warning btn-sm"
|
||||
title="{{'item.edit.metadata.edit.buttons.undo' | translate}}">
|
||||
<i class="fas fa-undo-alt fa-fw"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,15 @@
|
||||
@import '../../../../../styles/variables.scss';
|
||||
|
||||
.btn[disabled] {
|
||||
color: $gray-600;
|
||||
border-color: $gray-600;
|
||||
z-index: 0; // prevent border colors jumping on hover
|
||||
}
|
||||
|
||||
.relationship-action-buttons {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
@@ -0,0 +1,179 @@
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { EditRelationshipComponent } from './edit-relationship.component';
|
||||
import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { ResourceType } from '../../../../core/shared/resource-type';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { FieldChangeType } from '../../../../core/data/object-updates/object-updates.actions';
|
||||
|
||||
let objectUpdatesService: ObjectUpdatesService;
|
||||
const url = 'http://test-url.com/test-url';
|
||||
|
||||
let item;
|
||||
let author1;
|
||||
let author2;
|
||||
let fieldUpdate1;
|
||||
let fieldUpdate2;
|
||||
let relationships;
|
||||
let relationshipType;
|
||||
|
||||
let fixture;
|
||||
let comp: EditRelationshipComponent;
|
||||
let de;
|
||||
let el;
|
||||
|
||||
describe('EditRelationshipComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
relationshipType = Object.assign(new RelationshipType(), {
|
||||
id: '1',
|
||||
uuid: '1',
|
||||
leftwardType: 'isAuthorOfPublication',
|
||||
rightwardType: 'isPublicationOfAuthor'
|
||||
});
|
||||
|
||||
relationships = [
|
||||
Object.assign(new Relationship(), {
|
||||
self: url + '/2',
|
||||
id: '2',
|
||||
uuid: '2',
|
||||
leftId: 'author1',
|
||||
rightId: 'publication',
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType))
|
||||
}),
|
||||
Object.assign(new Relationship(), {
|
||||
self: url + '/3',
|
||||
id: '3',
|
||||
uuid: '3',
|
||||
leftId: 'author2',
|
||||
rightId: 'publication',
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType))
|
||||
})
|
||||
];
|
||||
|
||||
item = Object.assign(new Item(), {
|
||||
self: 'fake-item-url/publication',
|
||||
id: 'publication',
|
||||
uuid: 'publication',
|
||||
relationships: observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(new PageInfo(), relationships)))
|
||||
});
|
||||
|
||||
author1 = Object.assign(new Item(), {
|
||||
id: 'author1',
|
||||
uuid: 'author1'
|
||||
});
|
||||
author2 = Object.assign(new Item(), {
|
||||
id: 'author2',
|
||||
uuid: 'author2'
|
||||
});
|
||||
|
||||
fieldUpdate1 = {
|
||||
field: author1,
|
||||
changeType: undefined
|
||||
};
|
||||
fieldUpdate2 = {
|
||||
field: author2,
|
||||
changeType: FieldChangeType.REMOVE
|
||||
};
|
||||
|
||||
objectUpdatesService = jasmine.createSpyObj('objectUpdatesService',
|
||||
{
|
||||
saveChangeFieldUpdate: {},
|
||||
saveRemoveFieldUpdate: {},
|
||||
setEditableFieldUpdate: {},
|
||||
setValidFieldUpdate: {},
|
||||
removeSingleFieldUpdate: {},
|
||||
isEditable: observableOf(false), // should always return something --> its in ngOnInit
|
||||
isValid: observableOf(true) // should always return something --> its in ngOnInit
|
||||
}
|
||||
);
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot()],
|
||||
declarations: [EditRelationshipComponent],
|
||||
providers: [
|
||||
{ provide: ObjectUpdatesService, useValue: objectUpdatesService }
|
||||
], schemas: [
|
||||
NO_ERRORS_SCHEMA
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EditRelationshipComponent);
|
||||
comp = fixture.componentInstance;
|
||||
de = fixture.debugElement;
|
||||
el = de.nativeElement;
|
||||
|
||||
comp.url = url;
|
||||
comp.fieldUpdate = fieldUpdate1;
|
||||
comp.item = item;
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('when fieldUpdate has no changeType', () => {
|
||||
beforeEach(() => {
|
||||
comp.fieldUpdate = fieldUpdate1;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('canRemove', () => {
|
||||
it('should return true', () => {
|
||||
expect(comp.canRemove()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('canUndo', () => {
|
||||
it('should return false', () => {
|
||||
expect(comp.canUndo()).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when fieldUpdate has DELETE as changeType', () => {
|
||||
beforeEach(() => {
|
||||
comp.fieldUpdate = fieldUpdate2;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('canRemove', () => {
|
||||
it('should return false', () => {
|
||||
expect(comp.canRemove()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('canUndo', () => {
|
||||
it('should return true', () => {
|
||||
expect(comp.canUndo()).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('remove', () => {
|
||||
beforeEach(() => {
|
||||
comp.remove();
|
||||
});
|
||||
|
||||
it('should call saveRemoveFieldUpdate with the correct arguments', () => {
|
||||
expect(objectUpdatesService.saveRemoveFieldUpdate).toHaveBeenCalledWith(url, item);
|
||||
});
|
||||
});
|
||||
|
||||
describe('undo', () => {
|
||||
beforeEach(() => {
|
||||
comp.undo();
|
||||
});
|
||||
|
||||
it('should call removeSingleFieldUpdate with the correct arguments', () => {
|
||||
expect(objectUpdatesService.removeSingleFieldUpdate).toHaveBeenCalledWith(url, item.uuid);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -0,0 +1,74 @@
|
||||
import { Component, Input, OnChanges } from '@angular/core';
|
||||
import { FieldUpdate } from '../../../../core/data/object-updates/object-updates.reducer';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service';
|
||||
import { FieldChangeType } from '../../../../core/data/object-updates/object-updates.actions';
|
||||
import { ItemViewMode } from '../../../../shared/items/item-type-decorator';
|
||||
|
||||
@Component({
|
||||
// tslint:disable-next-line:component-selector
|
||||
selector: '[ds-edit-relationship]',
|
||||
styleUrls: ['./edit-relationship.component.scss'],
|
||||
templateUrl: './edit-relationship.component.html',
|
||||
})
|
||||
export class EditRelationshipComponent implements OnChanges {
|
||||
/**
|
||||
* The current field, value and state of the relationship
|
||||
*/
|
||||
@Input() fieldUpdate: FieldUpdate;
|
||||
|
||||
/**
|
||||
* The current url of this page
|
||||
*/
|
||||
@Input() url: string;
|
||||
|
||||
/**
|
||||
* The related item of this relationship
|
||||
*/
|
||||
item: Item;
|
||||
|
||||
/**
|
||||
* The view-mode we're currently on
|
||||
*/
|
||||
viewMode = ItemViewMode.Element;
|
||||
|
||||
constructor(private objectUpdatesService: ObjectUpdatesService) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current relationship based on the fieldUpdate input field
|
||||
*/
|
||||
ngOnChanges(): void {
|
||||
this.item = cloneDeep(this.fieldUpdate.field) as Item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a new remove update for this field to the object updates service
|
||||
*/
|
||||
remove(): void {
|
||||
this.objectUpdatesService.saveRemoveFieldUpdate(this.url, this.item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the current update for this field in the object updates service
|
||||
*/
|
||||
undo(): void {
|
||||
this.objectUpdatesService.removeSingleFieldUpdate(this.url, this.item.uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user should be allowed to remove this field
|
||||
*/
|
||||
canRemove(): boolean {
|
||||
return this.fieldUpdate.changeType !== FieldChangeType.REMOVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user should be allowed to cancel the update to this field
|
||||
*/
|
||||
canUndo(): boolean {
|
||||
return this.fieldUpdate.changeType >= 0;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
<div class="item-relationships">
|
||||
<div class="button-row top d-flex">
|
||||
<button class="btn btn-danger ml-auto" *ngIf="!(isReinstatable() | async)"
|
||||
[disabled]="!(hasChanges() | async)"
|
||||
(click)="discard()"><i
|
||||
class="fas fa-times"></i>
|
||||
<span class="d-none d-sm-inline"> {{"item.edit.metadata.discard-button" | translate}}</span>
|
||||
</button>
|
||||
<button class="btn btn-warning ml-auto" *ngIf="isReinstatable() | async"
|
||||
(click)="reinstate()"><i
|
||||
class="fas fa-undo-alt"></i>
|
||||
<span class="d-none d-sm-inline"> {{"item.edit.metadata.reinstate-button" | translate}}</span>
|
||||
</button>
|
||||
<button class="btn btn-primary" [disabled]="!(hasChanges() | async)"
|
||||
(click)="submit()"><i
|
||||
class="fas fa-save"></i>
|
||||
<span class="d-none d-sm-inline"> {{"item.edit.metadata.save-button" | translate}}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div *ngFor="let label of relationLabels$ | async" class="mb-4">
|
||||
<ds-edit-relationship-list [item]="item" [url]="url" [relationshipLabel]="label" ></ds-edit-relationship-list>
|
||||
</div>
|
||||
<div class="button-row bottom">
|
||||
<div class="float-right">
|
||||
<button class="btn btn-danger" *ngIf="!(isReinstatable() | async)"
|
||||
[disabled]="!(hasChanges() | async)"
|
||||
(click)="discard()"><i
|
||||
class="fas fa-times"></i>
|
||||
<span class="d-none d-sm-inline"> {{"item.edit.metadata.discard-button" | translate}}</span>
|
||||
</button>
|
||||
<button class="btn btn-warning" *ngIf="isReinstatable() | async"
|
||||
(click)="reinstate()"><i
|
||||
class="fas fa-undo-alt"></i>
|
||||
<span class="d-none d-sm-inline"> {{"item.edit.metadata.reinstate-button" | translate}}</span>
|
||||
</button>
|
||||
<button class="btn btn-primary" [disabled]="!(hasChanges() | async)"
|
||||
(click)="submit()"><i
|
||||
class="fas fa-save"></i>
|
||||
<span class="d-none d-sm-inline"> {{"item.edit.metadata.save-button" | translate}}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,22 @@
|
||||
@import '../../../../styles/variables.scss';
|
||||
|
||||
.button-row {
|
||||
.btn {
|
||||
margin-right: 0.5 * $spacer;
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
@media screen and (min-width: map-get($grid-breakpoints, sm)) {
|
||||
min-width: $edit-item-button-min-width;
|
||||
}
|
||||
}
|
||||
|
||||
&.top .btn {
|
||||
margin-top: $spacer/2;
|
||||
margin-bottom: $spacer/2;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,233 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ItemRelationshipsComponent } from './item-relationships.component';
|
||||
import { ChangeDetectorRef, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { INotification, Notification } from '../../../shared/notifications/models/notification.model';
|
||||
import { NotificationType } from '../../../shared/notifications/models/notification-type';
|
||||
import { RouterStub } from '../../../shared/testing/router-stub';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import { SharedModule } from '../../../shared/shared.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { ObjectUpdatesService } from '../../../core/data/object-updates/object-updates.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { GLOBAL_CONFIG } from '../../../../config';
|
||||
import { RelationshipType } from '../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { ResourceType } from '../../../core/shared/resource-type';
|
||||
import { Relationship } from '../../../core/shared/item-relationships/relationship.model';
|
||||
import { of as observableOf, combineLatest as observableCombineLatest } from 'rxjs';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../core/shared/page-info.model';
|
||||
import { FieldChangeType } from '../../../core/data/object-updates/object-updates.actions';
|
||||
import { RelationshipService } from '../../../core/data/relationship.service';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
import { getTestScheduler } from 'jasmine-marbles';
|
||||
import { RestResponse } from '../../../core/cache/response.models';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
|
||||
let comp: any;
|
||||
let fixture: ComponentFixture<ItemRelationshipsComponent>;
|
||||
let de: DebugElement;
|
||||
let el: HTMLElement;
|
||||
let objectUpdatesService;
|
||||
let relationshipService;
|
||||
let requestService;
|
||||
let objectCache;
|
||||
const infoNotification: INotification = new Notification('id', NotificationType.Info, 'info');
|
||||
const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning');
|
||||
const successNotification: INotification = new Notification('id', NotificationType.Success, 'success');
|
||||
const notificationsService = jasmine.createSpyObj('notificationsService',
|
||||
{
|
||||
info: infoNotification,
|
||||
warning: warningNotification,
|
||||
success: successNotification
|
||||
}
|
||||
);
|
||||
const router = new RouterStub();
|
||||
let routeStub;
|
||||
let itemService;
|
||||
|
||||
const url = 'http://test-url.com/test-url';
|
||||
router.url = url;
|
||||
|
||||
let scheduler: TestScheduler;
|
||||
let item;
|
||||
let author1;
|
||||
let author2;
|
||||
let fieldUpdate1;
|
||||
let fieldUpdate2;
|
||||
let relationships;
|
||||
let relationshipType;
|
||||
|
||||
describe('ItemRelationshipsComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
const date = new Date();
|
||||
|
||||
relationshipType = Object.assign(new RelationshipType(), {
|
||||
id: '1',
|
||||
uuid: '1',
|
||||
leftwardType: 'isAuthorOfPublication',
|
||||
rightwardType: 'isPublicationOfAuthor'
|
||||
});
|
||||
|
||||
relationships = [
|
||||
Object.assign(new Relationship(), {
|
||||
self: url + '/2',
|
||||
id: '2',
|
||||
uuid: '2',
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType))
|
||||
}),
|
||||
Object.assign(new Relationship(), {
|
||||
self: url + '/3',
|
||||
id: '3',
|
||||
uuid: '3',
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType))
|
||||
})
|
||||
];
|
||||
|
||||
item = Object.assign(new Item(), {
|
||||
self: 'fake-item-url/publication',
|
||||
id: 'publication',
|
||||
uuid: 'publication',
|
||||
relationships: observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(new PageInfo(), relationships))),
|
||||
lastModified: date
|
||||
});
|
||||
|
||||
author1 = Object.assign(new Item(), {
|
||||
id: 'author1',
|
||||
uuid: 'author1'
|
||||
});
|
||||
author2 = Object.assign(new Item(), {
|
||||
id: 'author2',
|
||||
uuid: 'author2'
|
||||
});
|
||||
|
||||
relationships[0].leftItem = observableOf(new RemoteData(false, false, true, undefined, author1));
|
||||
relationships[0].rightItem = observableOf(new RemoteData(false, false, true, undefined, item));
|
||||
relationships[1].leftItem = observableOf(new RemoteData(false, false, true, undefined, author2));
|
||||
relationships[1].rightItem = observableOf(new RemoteData(false, false, true, undefined, item));
|
||||
|
||||
fieldUpdate1 = {
|
||||
field: author1,
|
||||
changeType: undefined
|
||||
};
|
||||
fieldUpdate2 = {
|
||||
field: author2,
|
||||
changeType: FieldChangeType.REMOVE
|
||||
};
|
||||
|
||||
itemService = jasmine.createSpyObj('itemService', {
|
||||
findById: observableOf(new RemoteData(false, false, true, undefined, item))
|
||||
});
|
||||
routeStub = {
|
||||
parent: {
|
||||
data: observableOf({ item: new RemoteData(false, false, true, null, item) })
|
||||
}
|
||||
};
|
||||
|
||||
objectUpdatesService = jasmine.createSpyObj('objectUpdatesService',
|
||||
{
|
||||
getFieldUpdates: observableOf({
|
||||
[author1.uuid]: fieldUpdate1,
|
||||
[author2.uuid]: fieldUpdate2
|
||||
}),
|
||||
getFieldUpdatesExclusive: observableOf({
|
||||
[author1.uuid]: fieldUpdate1,
|
||||
[author2.uuid]: fieldUpdate2
|
||||
}),
|
||||
saveAddFieldUpdate: {},
|
||||
discardFieldUpdates: {},
|
||||
reinstateFieldUpdates: observableOf(true),
|
||||
initialize: {},
|
||||
getUpdatedFields: observableOf([author1, author2]),
|
||||
getLastModified: observableOf(date),
|
||||
hasUpdates: observableOf(true),
|
||||
isReinstatable: observableOf(false), // should always return something --> its in ngOnInit
|
||||
isValidPage: observableOf(true)
|
||||
}
|
||||
);
|
||||
|
||||
relationshipService = jasmine.createSpyObj('relationshipService',
|
||||
{
|
||||
getItemRelationshipLabels: observableOf(['isAuthorOfPublication']),
|
||||
getRelatedItems: observableOf([author1, author2]),
|
||||
getRelatedItemsByLabel: observableOf([author1, author2]),
|
||||
getItemRelationshipsArray: observableOf(relationships),
|
||||
deleteRelationship: observableOf(new RestResponse(true, 200, 'OK')),
|
||||
getItemResolvedRelatedItemsAndRelationships: observableCombineLatest(observableOf([author1, author2]), observableOf([item, item]), observableOf(relationships))
|
||||
}
|
||||
);
|
||||
|
||||
requestService = jasmine.createSpyObj('requestService',
|
||||
{
|
||||
removeByHrefSubstring: {},
|
||||
hasByHrefObservable: observableOf(false)
|
||||
}
|
||||
);
|
||||
|
||||
objectCache = jasmine.createSpyObj('objectCache', {
|
||||
remove: undefined
|
||||
});
|
||||
|
||||
scheduler = getTestScheduler();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [SharedModule, TranslateModule.forRoot()],
|
||||
declarations: [ItemRelationshipsComponent],
|
||||
providers: [
|
||||
{ provide: ItemDataService, useValue: itemService },
|
||||
{ provide: ObjectUpdatesService, useValue: objectUpdatesService },
|
||||
{ provide: Router, useValue: router },
|
||||
{ provide: ActivatedRoute, useValue: routeStub },
|
||||
{ provide: NotificationsService, useValue: notificationsService },
|
||||
{ provide: GLOBAL_CONFIG, useValue: { item: { edit: { undoTimeout: 10 } } } as any },
|
||||
{ provide: RelationshipService, useValue: relationshipService },
|
||||
{ provide: ObjectCacheService, useValue: objectCache },
|
||||
{ provide: RequestService, useValue: requestService },
|
||||
ChangeDetectorRef
|
||||
], schemas: [
|
||||
NO_ERRORS_SCHEMA
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ItemRelationshipsComponent);
|
||||
comp = fixture.componentInstance;
|
||||
de = fixture.debugElement;
|
||||
el = de.nativeElement;
|
||||
comp.url = url;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('discard', () => {
|
||||
beforeEach(() => {
|
||||
comp.discard();
|
||||
});
|
||||
|
||||
it('it should call discardFieldUpdates on the objectUpdatesService with the correct url and notification', () => {
|
||||
expect(objectUpdatesService.discardFieldUpdates).toHaveBeenCalledWith(url, infoNotification);
|
||||
});
|
||||
});
|
||||
|
||||
describe('reinstate', () => {
|
||||
beforeEach(() => {
|
||||
comp.reinstate();
|
||||
});
|
||||
|
||||
it('it should call reinstateFieldUpdates on the objectUpdatesService with the correct url', () => {
|
||||
expect(objectUpdatesService.reinstateFieldUpdates).toHaveBeenCalledWith(url);
|
||||
});
|
||||
});
|
||||
|
||||
describe('submit', () => {
|
||||
beforeEach(() => {
|
||||
comp.submit();
|
||||
});
|
||||
|
||||
it('it should delete the correct relationship', () => {
|
||||
expect(relationshipService.deleteRelationship).toHaveBeenCalledWith(relationships[1].uuid);
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,172 @@
|
||||
import { ChangeDetectorRef, Component, Inject, OnDestroy } from '@angular/core';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { FieldUpdate, FieldUpdates } from '../../../core/data/object-updates/object-updates.reducer';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { filter, map, switchMap, take, tap } from 'rxjs/operators';
|
||||
import { combineLatest as observableCombineLatest, zip as observableZip } from 'rxjs';
|
||||
import { AbstractItemUpdateComponent } from '../abstract-item-update/abstract-item-update.component';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { ObjectUpdatesService } from '../../../core/data/object-updates/object-updates.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config';
|
||||
import { RelationshipService } from '../../../core/data/relationship.service';
|
||||
import { FieldChangeType } from '../../../core/data/object-updates/object-updates.actions';
|
||||
import { Relationship } from '../../../core/shared/item-relationships/relationship.model';
|
||||
import { ErrorResponse, RestResponse } from '../../../core/cache/response.models';
|
||||
import { isNotEmptyOperator } from '../../../shared/empty.util';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
import { getSucceededRemoteData } from '../../../core/shared/operators';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { Subscription } from 'rxjs/internal/Subscription';
|
||||
import { getRelationsByRelatedItemIds } from '../../simple/item-types/shared/item-relationships-utils';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-relationships',
|
||||
styleUrls: ['./item-relationships.component.scss'],
|
||||
templateUrl: './item-relationships.component.html',
|
||||
})
|
||||
/**
|
||||
* Component for displaying an item's relationships edit page
|
||||
*/
|
||||
export class ItemRelationshipsComponent extends AbstractItemUpdateComponent implements OnDestroy {
|
||||
|
||||
/**
|
||||
* The labels of all different relations within this item
|
||||
*/
|
||||
relationLabels$: Observable<string[]>;
|
||||
|
||||
/**
|
||||
* A subscription that checks when the item is deleted in cache and reloads the item by sending a new request
|
||||
* This is used to update the item in cache after relationships are deleted
|
||||
*/
|
||||
itemUpdateSubscription: Subscription;
|
||||
|
||||
constructor(
|
||||
protected itemService: ItemDataService,
|
||||
protected objectUpdatesService: ObjectUpdatesService,
|
||||
protected router: Router,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected translateService: TranslateService,
|
||||
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||
protected route: ActivatedRoute,
|
||||
protected relationshipService: RelationshipService,
|
||||
protected objectCache: ObjectCacheService,
|
||||
protected requestService: RequestService,
|
||||
protected cdRef: ChangeDetectorRef
|
||||
) {
|
||||
super(itemService, objectUpdatesService, router, notificationsService, translateService, EnvConfig, route);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up and initialize all fields
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
super.ngOnInit();
|
||||
this.relationLabels$ = this.relationshipService.getItemRelationshipLabels(this.item);
|
||||
this.initializeItemUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the item (and view) when it's removed in the request cache
|
||||
*/
|
||||
public initializeItemUpdate(): void {
|
||||
this.itemUpdateSubscription = this.requestService.hasByHrefObservable(this.item.self).pipe(
|
||||
filter((exists: boolean) => !exists),
|
||||
switchMap(() => this.itemService.findById(this.item.uuid)),
|
||||
getSucceededRemoteData(),
|
||||
).subscribe((itemRD: RemoteData<Item>) => {
|
||||
this.item = itemRD.payload;
|
||||
this.cdRef.detectChanges();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the values and updates of the current item's relationship fields
|
||||
*/
|
||||
public initializeUpdates(): void {
|
||||
this.updates$ = this.relationshipService.getRelatedItems(this.item).pipe(
|
||||
switchMap((items: Item[]) => this.objectUpdatesService.getFieldUpdates(this.url, items))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the prefix for notification messages
|
||||
*/
|
||||
public initializeNotificationsPrefix(): void {
|
||||
this.notificationsPrefix = 'item.edit.relationships.notifications.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the currently selected related items back to relationships and send a delete request for each of the relationships found
|
||||
* Make sure the lists are refreshed afterwards and notifications are sent for success and errors
|
||||
*/
|
||||
public submit(): void {
|
||||
// Get all IDs of related items of which their relationship with the current item is about to be removed
|
||||
const removedItemIds$ = this.relationshipService.getRelatedItems(this.item).pipe(
|
||||
switchMap((items: Item[]) => this.objectUpdatesService.getFieldUpdatesExclusive(this.url, items) as Observable<FieldUpdates>),
|
||||
map((fieldUpdates: FieldUpdates) => Object.values(fieldUpdates).filter((fieldUpdate: FieldUpdate) => fieldUpdate.changeType === FieldChangeType.REMOVE)),
|
||||
map((fieldUpdates: FieldUpdate[]) => fieldUpdates.map((fieldUpdate: FieldUpdate) => fieldUpdate.field.uuid) as string[]),
|
||||
isNotEmptyOperator()
|
||||
);
|
||||
// Get all the relationships that should be removed
|
||||
const removedRelationships$ = removedItemIds$.pipe(
|
||||
getRelationsByRelatedItemIds(this.item, this.relationshipService)
|
||||
);
|
||||
// Request a delete for every relationship found in the observable created above
|
||||
removedRelationships$.pipe(
|
||||
take(1),
|
||||
map((removedRelationships: Relationship[]) => removedRelationships.map((rel: Relationship) => rel.id)),
|
||||
switchMap((removedIds: string[]) => observableZip(...removedIds.map((uuid: string) => this.relationshipService.deleteRelationship(uuid))))
|
||||
).subscribe((responses: RestResponse[]) => {
|
||||
this.displayNotifications(responses);
|
||||
this.reset();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display notifications
|
||||
* - Error notification for each failed response with their message
|
||||
* - Success notification in case there's at least one successful response
|
||||
* @param responses
|
||||
*/
|
||||
displayNotifications(responses: RestResponse[]) {
|
||||
const failedResponses = responses.filter((response: RestResponse) => !response.isSuccessful);
|
||||
const successfulResponses = responses.filter((response: RestResponse) => response.isSuccessful);
|
||||
|
||||
failedResponses.forEach((response: ErrorResponse) => {
|
||||
this.notificationsService.error(this.getNotificationTitle('failed'), response.errorMessage);
|
||||
});
|
||||
if (successfulResponses.length > 0) {
|
||||
this.notificationsService.success(this.getNotificationTitle('saved'), this.getNotificationContent('saved'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-initialize fields and subscriptions
|
||||
*/
|
||||
reset() {
|
||||
this.initializeOriginalFields();
|
||||
this.initializeUpdates();
|
||||
this.initializeItemUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends all initial values of this item to the object updates service
|
||||
*/
|
||||
public initializeOriginalFields() {
|
||||
this.relationshipService.getRelatedItems(this.item).pipe(take(1)).subscribe((items: Item[]) => {
|
||||
this.objectUpdatesService.initialize(this.url, items, this.item.lastModified);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe from the item update when the component is destroyed
|
||||
*/
|
||||
ngOnDestroy(): void {
|
||||
this.itemUpdateSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
}
|
@@ -68,6 +68,7 @@ export class ItemStatusComponent implements OnInit {
|
||||
The value is supposed to be a href for the button
|
||||
*/
|
||||
this.operations = [];
|
||||
this.operations.push(new ItemOperation('mappedCollections', this.getCurrentUrl(item) + '/mapper'));
|
||||
if (item.isWithdrawn) {
|
||||
this.operations.push(new ItemOperation('reinstate', this.getCurrentUrl(item) + '/reinstate'));
|
||||
} else {
|
||||
@@ -79,6 +80,7 @@ export class ItemStatusComponent implements OnInit {
|
||||
this.operations.push(new ItemOperation('public', this.getCurrentUrl(item) + '/public'));
|
||||
}
|
||||
this.operations.push(new ItemOperation('delete', this.getCurrentUrl(item) + '/delete'));
|
||||
this.operations.push(new ItemOperation('move', this.getCurrentUrl(item) + '/move'));
|
||||
});
|
||||
|
||||
}
|
||||
|
@@ -31,8 +31,8 @@ import { MetadataFieldWrapperComponent } from './field-components/metadata-field
|
||||
imports: [
|
||||
CommonModule,
|
||||
SharedModule,
|
||||
EditItemPageModule,
|
||||
ItemPageRoutingModule,
|
||||
EditItemPageModule,
|
||||
SearchPageModule
|
||||
],
|
||||
declarations: [
|
||||
@@ -62,7 +62,8 @@ import { MetadataFieldWrapperComponent } from './field-components/metadata-field
|
||||
GenericItemPageFieldComponent,
|
||||
RelatedEntitiesSearchComponent,
|
||||
RelatedItemsComponent,
|
||||
MetadataRepresentationListComponent
|
||||
MetadataRepresentationListComponent,
|
||||
ItemPageTitleFieldComponent
|
||||
],
|
||||
entryComponents: [
|
||||
PublicationComponent
|
||||
|
@@ -7,10 +7,12 @@ import { hasNoValue, hasValue } from '../../../../shared/empty.util';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { distinctUntilChanged, flatMap, map, switchMap } from 'rxjs/operators';
|
||||
import { distinctUntilChanged, filter, flatMap, map, switchMap, tap } from 'rxjs/operators';
|
||||
import { of as observableOf, zip as observableZip, combineLatest as observableCombineLatest } from 'rxjs';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { RelationshipService } from '../../../../core/data/relationship.service';
|
||||
|
||||
/**
|
||||
* Operator for comparing arrays using a mapping function
|
||||
@@ -58,10 +60,10 @@ export const filterRelationsByTypeLabel = (label: string, thisId?: string) =>
|
||||
return relatedItems$.pipe(
|
||||
map((arr) => relsCurrentPage.filter((rel: Relationship, idx: number) =>
|
||||
hasValue(relTypesCurrentPage[idx]) && (
|
||||
(hasNoValue(thisId) && (relTypesCurrentPage[idx].leftLabel === label ||
|
||||
relTypesCurrentPage[idx].rightLabel === label)) ||
|
||||
(thisId === arr[idx][0].id && relTypesCurrentPage[idx].leftLabel === label) ||
|
||||
(thisId === arr[idx][1].id && relTypesCurrentPage[idx].rightLabel === label)
|
||||
(hasNoValue(thisId) && (relTypesCurrentPage[idx].leftwardType === label ||
|
||||
relTypesCurrentPage[idx].rightwardType === label)) ||
|
||||
(thisId === arr[idx][0].id && relTypesCurrentPage[idx].leftwardType === label) ||
|
||||
(thisId === arr[idx][1].id && relTypesCurrentPage[idx].rightwardType === label)
|
||||
)
|
||||
))
|
||||
);
|
||||
@@ -147,3 +149,17 @@ export const relationsToRepresentations = (parentId: string, itemType: string, m
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Operator for fetching an item's relationships, but filtered by related item IDs (essentially performing a reverse lookup)
|
||||
* Only relationships where leftItem or rightItem's ID is present in the list provided will be returned
|
||||
* @param item
|
||||
* @param relationshipService
|
||||
*/
|
||||
export const getRelationsByRelatedItemIds = (item: Item, relationshipService: RelationshipService) =>
|
||||
(source: Observable<string[]>): Observable<Relationship[]> =>
|
||||
source.pipe(
|
||||
flatMap((relatedItemIds: string[]) => relationshipService.getItemResolvedRelatedItemsAndRelationships(item).pipe(
|
||||
map(([leftItems, rightItems, rels]) => rels.filter((rel: Relationship, index: number) => relatedItemIds.indexOf(leftItems[index].uuid) > -1 || relatedItemIds.indexOf(rightItems[index].uuid) > -1))
|
||||
))
|
||||
);
|
||||
|
@@ -3,7 +3,8 @@
|
||||
<div>
|
||||
<img class="mb-4 login-logo" src="assets/images/dspace-logo.png">
|
||||
<h1 class="h3 mb-0 font-weight-normal">{{"login.form.header" | translate}}</h1>
|
||||
<ds-log-in></ds-log-in>
|
||||
<ds-log-in
|
||||
[isStandalonePage]="true"></ds-log-in>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -8,7 +8,7 @@ import { MyDSpaceConfigurationValueType } from './my-dspace-configuration-value-
|
||||
import { RoleService } from '../core/roles/role.service';
|
||||
import { SearchConfigurationOption } from '../+search-page/search-switch-configuration/search-configuration-option.model';
|
||||
import { SearchConfigurationService } from '../+search-page/search-service/search-configuration.service';
|
||||
import { RouteService } from '../shared/services/route.service';
|
||||
import { RouteService } from '../core/services/route.service';
|
||||
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
|
||||
import { SearchFixedFilterService } from '../+search-page/search-filters/search-filter/search-fixed-filter.service';
|
||||
|
@@ -17,7 +17,7 @@ import { HostWindowService } from '../shared/host-window.service';
|
||||
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
|
||||
import { RemoteData } from '../core/data/remote-data';
|
||||
import { MyDSpacePageComponent, SEARCH_CONFIG_SERVICE } from './my-dspace-page.component';
|
||||
import { RouteService } from '../shared/services/route.service';
|
||||
import { RouteService } from '../core/services/route.service';
|
||||
import { routeServiceStub } from '../shared/testing/route-service-stub';
|
||||
import { SearchConfigurationServiceStub } from '../shared/testing/search-configuration-service-stub';
|
||||
import { SearchService } from '../+search-page/search-service/search.service';
|
||||
@@ -82,9 +82,6 @@ describe('MyDSpacePageComponent', () => {
|
||||
expand: () => this.isCollapsed = observableOf(false)
|
||||
};
|
||||
const mockFixedFilterService: SearchFixedFilterService = {
|
||||
getQueryByFilterName: (filter: string) => {
|
||||
return observableOf(undefined)
|
||||
}
|
||||
} as SearchFixedFilterService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
@@ -4,12 +4,12 @@ import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
|
||||
import { SearchPageComponent } from './search-page.component';
|
||||
import { ChangeDetectionStrategy, Component, Inject, Input, OnInit } from '@angular/core';
|
||||
import { pushInOut } from '../shared/animations/push';
|
||||
import { RouteService } from '../shared/services/route.service';
|
||||
import { SearchConfigurationService } from './search-service/search-configuration.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PaginatedSearchOptions } from './paginated-search-options.model';
|
||||
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { RouteService } from '../core/services/route.service';
|
||||
|
||||
/**
|
||||
* This component renders a search page using a configuration as input.
|
||||
|
@@ -4,12 +4,12 @@ import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
|
||||
import { SearchPageComponent } from './search-page.component';
|
||||
import { ChangeDetectionStrategy, Component, Inject, Input, OnInit } from '@angular/core';
|
||||
import { pushInOut } from '../shared/animations/push';
|
||||
import { RouteService } from '../shared/services/route.service';
|
||||
import { SearchConfigurationService } from './search-service/search-configuration.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PaginatedSearchOptions } from './paginated-search-options.model';
|
||||
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { RouteService } from '../core/services/route.service';
|
||||
|
||||
/**
|
||||
* This component renders a simple item page.
|
||||
|
@@ -15,13 +15,13 @@
|
||||
| translate}}</a>
|
||||
</div>
|
||||
</div>
|
||||
<ds-input-suggestions [suggestions]="(filterSearchResults | async)"
|
||||
<ds-filter-input-suggestions [suggestions]="(filterSearchResults | async)"
|
||||
[placeholder]="'search.filters.filter.' + filterConfig.name + '.placeholder'| translate"
|
||||
[action]="getCurrentUrl()"
|
||||
[action]="currentUrl"
|
||||
[name]="filterConfig.paramName"
|
||||
[(ngModel)]="filter"
|
||||
(submitSuggestion)="onSubmit($event)"
|
||||
(clickSuggestion)="onSubmit($event)"
|
||||
(findSuggestions)="findSuggestions($event)"
|
||||
ngDefaultControl></ds-input-suggestions>
|
||||
ngDefaultControl></ds-filter-input-suggestions>
|
||||
</div>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<a *ngIf="isVisible | async" class="d-flex flex-row"
|
||||
[routerLink]="[getSearchLink()]"
|
||||
[routerLink]="[searchLink]"
|
||||
[queryParams]="addQueryParams" queryParamsHandling="merge">
|
||||
<input type="checkbox" [checked]="false" class="my-1 align-self-stretch"/>
|
||||
<span class="filter-value px-1">{{filterValue.value}}</span>
|
||||
|
@@ -50,6 +50,10 @@ export class SearchFacetOptionComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
addQueryParams;
|
||||
|
||||
/**
|
||||
* Link to the search page
|
||||
*/
|
||||
searchLink: string;
|
||||
/**
|
||||
* Subscription to unsubscribe from on destroy
|
||||
*/
|
||||
@@ -66,6 +70,7 @@ export class SearchFacetOptionComponent implements OnInit, OnDestroy {
|
||||
* Initializes all observable instance variables and starts listening to them
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.searchLink = this.getSearchLink();
|
||||
this.isVisible = this.isChecked().pipe(map((checked: boolean) => !checked));
|
||||
this.sub = observableCombineLatest(this.selectedValues$, this.searchConfigService.searchOptions)
|
||||
.subscribe(([selectedValues, searchOptions]) => {
|
||||
@@ -83,7 +88,7 @@ export class SearchFacetOptionComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* @returns {string} The base path to the search page, or the current page when inPlaceSearch is true
|
||||
*/
|
||||
public getSearchLink(): string {
|
||||
private getSearchLink(): string {
|
||||
if (this.inPlaceSearch) {
|
||||
return './';
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<a *ngIf="isVisible | async" class="d-flex flex-row"
|
||||
[routerLink]="[getSearchLink()]"
|
||||
[routerLink]="[searchLink]"
|
||||
[queryParams]="changeQueryParams" queryParamsHandling="merge">
|
||||
<span class="filter-value px-1">{{filterValue.label}}</span>
|
||||
<span class="float-right filter-value-count ml-auto">
|
||||
|
@@ -56,6 +56,11 @@ export class SearchFacetRangeOptionComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
sub: Subscription;
|
||||
|
||||
/**
|
||||
* Link to the search page
|
||||
*/
|
||||
searchLink: string;
|
||||
|
||||
constructor(protected searchService: SearchService,
|
||||
protected filterService: SearchFilterService,
|
||||
protected searchConfigService: SearchConfigurationService,
|
||||
@@ -67,6 +72,7 @@ export class SearchFacetRangeOptionComponent implements OnInit, OnDestroy {
|
||||
* Initializes all observable instance variables and starts listening to them
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.searchLink = this.getSearchLink();
|
||||
this.isVisible = this.isChecked().pipe(map((checked: boolean) => !checked));
|
||||
this.sub = this.searchConfigService.searchOptions.subscribe(() => {
|
||||
this.updateChangeParams()
|
||||
@@ -83,7 +89,7 @@ export class SearchFacetRangeOptionComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* @returns {string} The base path to the search page, or the current page when inPlaceSearch is true
|
||||
*/
|
||||
public getSearchLink(): string {
|
||||
private getSearchLink(): string {
|
||||
if (this.inPlaceSearch) {
|
||||
return './';
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<a class="d-flex flex-row"
|
||||
[routerLink]="[getSearchLink()]"
|
||||
[routerLink]="[searchLink]"
|
||||
[queryParams]="removeQueryParams" queryParamsHandling="merge">
|
||||
<input type="checkbox" [checked]="true" class="my-1 align-self-stretch"/>
|
||||
<span class="filter-value pl-1 text-capitalize">{{selectedValue.label}}</span>
|
||||
|
@@ -49,6 +49,11 @@ export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
sub: Subscription;
|
||||
|
||||
/**
|
||||
* Link to the search page
|
||||
*/
|
||||
searchLink: string;
|
||||
|
||||
constructor(protected searchService: SearchService,
|
||||
protected filterService: SearchFilterService,
|
||||
protected searchConfigService: SearchConfigurationService,
|
||||
@@ -64,12 +69,13 @@ export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy {
|
||||
.subscribe(([selectedValues, searchOptions]) => {
|
||||
this.updateRemoveParams(selectedValues)
|
||||
});
|
||||
this.searchLink = this.getSearchLink();
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} The base path to the search page, or the current page when inPlaceSearch is true
|
||||
*/
|
||||
public getSearchLink(): string {
|
||||
private getSearchLink(): string {
|
||||
if (this.inPlaceSearch) {
|
||||
return './';
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user