Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from ror-community/license_display
Browse files Browse the repository at this point in the history
License display
  • Loading branch information
eshadatta-crossref authored Dec 15, 2021
2 parents a643611 + 35148fb commit 45acb2b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VUE_APP_GENERATE_ID="http://localhost:5000/generateid?mode=dev"
VUE_APP_GENERATE_ID="http://localhost:5000/generateid"
6 changes: 4 additions & 2 deletions src/components/CustomRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { useVuetifyControl } from '@jsonforms/vue2-vuetify';
import { VTextField } from 'vuetify/lib';
import { CoreActions } from '@jsonforms/core';
import set from 'lodash/fp/set';
import { env } from '../env';
export const customRenderer = defineComponent({
name: 'custom-renderer',
Expand Down Expand Up @@ -142,8 +143,9 @@ export const customRenderer = defineComponent({
return data;
},
fetchAddress(id: string, path: string) {
const url = new URL('http://api.geonames.org/getJSON');
const params = { geonameId: id, username: 'roradmin' }; // or:
const url = new URL(env().GEONAMES_URL);
const username = env().GEONAMES_USERNAME
const params = { geonameId: id, username: username }; // or:
url.search = new URLSearchParams(params).toString();
const rootData = this.jsonforms?.core?.data;
fetch(url.toString()).then((response) => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/NewRecord.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { langEntry } from './ShowLanguageRenderer.vue';
import { typeEntry } from './ShowTypes.vue';
import { genListEntry } from './GenerateListRenderer.vue';
import { input as rorSchema } from "@/jsonSchema/rorSchema";
import { env } from '../env';
const renderers = [
Expand All @@ -56,7 +57,7 @@ export default defineComponent({
data () {
const data: Record<string, any> = {};
const errors: any = ref(undefined)
const validForm: boolean = false
const validForm: boolean = false
return {
// freeze renderers for performance gains
renderers: Object.freeze(renderers),
Expand All @@ -72,7 +73,7 @@ export default defineComponent({
this.index++
},
getRORId () {
const url = new URL(process.env.VUE_APP_GENERATE_ID)
const url = new URL(env().GENERATE_ID)
return new Promise(resolve => {
fetch(url.toString()).then((response) => {
if (response.ok) {
Expand Down
10 changes: 10 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const env = () => {
const {
VUE_APP_BASE_ROUTE: BASE_ROUTE = '/',
VUE_APP_GENERATE_ID: GENERATE_ID = 'http://localhost:5000/generateid?mode=dev',
VUE_APP_GEONAMES_URL: GEONAMES_URL = 'http://api.geonames.org/getJSON',
VUE_APP_GEONAMES_USERNAME: GEONAMES_USERNAME = 'roradmin',
NODE_ENV
} = process.env;
return { BASE_ROUTE, GENERATE_ID, GEONAMES_URL, GEONAMES_USERNAME, NODE_ENV };
};
1 change: 1 addition & 0 deletions src/jsonSchema/rorSchema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"license": {
"type": "object",
"additionalProperties": false,
"default": {},
"properties": {
"attribution": {
"readOnly": true,
Expand Down
21 changes: 21 additions & 0 deletions src/jsonSchema/rorSchema/uischema.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,27 @@
}
}
},
{
"type": "HorizontalLayout",
"elements": [
{
"type": "Control",
"label": "License Attribution",
"scope": "#/properties/addresses/items/properties/geonames_city/properties/license/properties/attribution",
"rule": {
"effect": "HIDE"
}
},
{
"type": "Control",
"label": "License URL",
"scope": "#/properties/addresses/items/properties/geonames_city/properties/license/properties/license",
"rule": {
"effect": "HIDE"
}
}
]
},
{
"type": "HorizontalLayout",
"elements": [
Expand Down

0 comments on commit 45acb2b

Please sign in to comment.