Skip to content

Commit

Permalink
BASIRA #275 - Adding authorized_vocabulary and authorized_vocabulary_…
Browse files Browse the repository at this point in the history
…url fields to places
  • Loading branch information
dleadbetter committed Dec 11, 2024
1 parent 3e451e2 commit 09fdfb7
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/controllers/api/places_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
class Api::PlacesController < Api::BaseController
# Search attributes
search_attributes :name, :city, :state, :country

# Preloads
preloads :qualifications, only: :show
end
6 changes: 4 additions & 2 deletions app/models/place.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Place < ApplicationRecord
# Includes
include Qualifiable
include Recordable
include Search::Place

Expand All @@ -11,6 +12,7 @@ class Place < ApplicationRecord

# Resourceable parameters
allow_params :name, :place_type, :lat, :long, :city, :state, :country, :url, :database_value, :notes, :same_as,
:part_of, locations_attributes: [:id, :locateable_id, :locateable_type, :description, :certainty,
:notes, :_destroy, qualifications_attributes: [:id, :value_list_id, :notes, :persistent, :_destroy]]
:part_of, :authorized_vocabulary_url,
locations_attributes: [:id, :locateable_id, :locateable_type, :description, :certainty, :notes, :_destroy,
qualifications_attributes: [:id, :value_list_id, :notes, :persistent, :_destroy]]
end
3 changes: 2 additions & 1 deletion app/serializers/places_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class PlacesSerializer < BaseSerializer
index_attributes :id, :name, :place_type, :lat, :long, :city, :state, :country
show_attributes :id, :name, :place_type, :lat, :long, :city, :state, :country, :url, :database_value, :notes, :same_as, :part_of
show_attributes :id, :name, :place_type, :lat, :long, :city, :state, :country, :url, :database_value, :notes,
:same_as, :part_of, :authorized_vocabulary_url, qualifications: QualificationsSerializer

# For unauthenticated users, only display locations for artworks that are published
show_attributes(:locations) do |place, current_user|
Expand Down
14 changes: 14 additions & 0 deletions client/src/components/PlaceForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { GoogleScript } from '@performant-software/shared-components';
import { Form, Grid } from 'semantic-ui-react';
import _ from 'underscore';
import Countries from '../resources/Countries.json';
import ValueListDropdown from './ValueListDropdown';

import type { EditContainerProps } from 'react-components/types';
import type { Translateable } from '../types/Translateable';
Expand Down Expand Up @@ -110,6 +111,19 @@ const PlaceForm = (props: Props) => {
onChange={props.onTextInputChange.bind(this, 'url')}
value={props.item.url || ''}
/>
<ValueListDropdown
{...props}
group='Authorized Vocabulary'
label={props.t('Place.labels.authorizedVocabulary')}
object='General'
/>
<Form.Input
error={props.isError('authorized_vocabulary_url')}
label={props.t('Place.labels.authorizedVocabularyUrl')}
required={props.isRequired('authorized_vocabulary_url')}
onChange={props.onTextInputChange.bind(this, 'authorized_vocabulary_url')}
value={props.item.authorized_vocabulary_url || ''}
/>
<Form.Input
error={props.isError('database_value')}
label={props.t('Place.labels.databaseValue')}
Expand Down
4 changes: 3 additions & 1 deletion client/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@
"notes": "Notes",
"state": "State",
"type": "Type",
"url": "Institutional URL"
"url": "Institutional URL",
"authorizedVocabulary": "Authorized vocabulary",
"authorizedVocabularyUrl": "Authorized vocabulary URL"
},
"locations": {
"columns": {
Expand Down
7 changes: 5 additions & 2 deletions client/src/transforms/Place.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import _ from 'underscore';
import BaseTransform from './BaseTransform';
import Locations from './Locations';
import Qualifications from './Qualifications';

import type { Place as PlaceType } from '../types/Place';

Expand All @@ -28,7 +29,8 @@ class Place extends BaseTransform {
'database_value',
'notes',
'same_as',
'part_of'
'part_of',
'authorized_vocabulary_url'
];
}

Expand Down Expand Up @@ -59,7 +61,8 @@ class Place extends BaseTransform {
return {
place: {
..._.pick(place, this.getPayloadKeys()),
...Locations.toPayload(place)
...Locations.toPayload(place),
...Qualifications.toPayload(place)
}
};
}
Expand Down
1 change: 1 addition & 0 deletions client/src/types/Place.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Place = {
notes: string,
same_as: number,
part_of: number,
authorized_vocabulary_url,

locations: Array<Location>
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddAuthorizedVocabularyUrlToPlaces < ActiveRecord::Migration[7.0]
def change
add_column :places, :authorized_vocabulary_url, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_12_11_201922) do
ActiveRecord::Schema[7.0].define(version: 2024_12_11_202543) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "plpgsql"
Expand Down Expand Up @@ -235,6 +235,7 @@
t.datetime "updated_at", null: false
t.bigint "created_by_id"
t.bigint "updated_by_id"
t.string "authorized_vocabulary_url"
t.index ["created_by_id"], name: "index_places_on_created_by_id"
t.index ["updated_by_id"], name: "index_places_on_updated_by_id"
end
Expand Down

0 comments on commit 09fdfb7

Please sign in to comment.