Skip to content

Commit

Permalink
BASIRA #254 - Removing "sewing_supports_visible" column from document…
Browse files Browse the repository at this point in the history
…s; Defaulting "number_sewing_supports" to "0"
  • Loading branch information
dleadbetter committed Nov 27, 2024
1 parent e7f85aa commit 8a47b77
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 43 deletions.
2 changes: 1 addition & 1 deletion app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Document < ApplicationRecord
after_create :set_actor_type

# Resourceable parameters
allow_params :visual_context_id, :name, :notes, :sewing_supports_visible, :number_sewing_supports, :number_fastenings,
allow_params :visual_context_id, :name, :notes, :number_sewing_supports, :number_fastenings,
:inscriptions_on_binding, :inscription_text, :endband_present, :uncut_fore_edges, :fore_edge_text,
:bookmarks_registers, :text_columns, :ruling, :rubrication, :identity, :transcription, :transcription_expanded,
:transcription_translation, :artwork_id, actions_attributes: [:id, :notes, :_destroy,
Expand Down
1 change: 0 additions & 1 deletion app/models/search/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def published
search_attribute :aperture, object: 'Document', group: 'Aperture', facet: true
search_attribute :binding_type, object: 'Document', group: 'Binding Type', multiple: true, facet: true
search_attribute :binding_color, object: 'Document', group: 'Color', form_field: 'binding_color', multiple: true, facet: true
search_attribute :sewing_supports_visible, facet: true
search_attribute :number_sewing_supports, facet: true
search_attribute :spine_features, object: 'Document', group: 'Spine Features', multiple: true, facet: true
search_attribute :furniture, object: 'Document', group: 'Furniture', multiple: true, facet: true
Expand Down
8 changes: 4 additions & 4 deletions app/serializers/documents_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ class DocumentsSerializer < BaseSerializer

index_attributes :id, :name

show_attributes :id, :name, :visual_context_id, :notes, :sewing_supports_visible, :number_sewing_supports,
:number_fastenings, :inscriptions_on_binding, :inscription_text, :endband_present,
:uncut_fore_edges, :fore_edge_text, :bookmarks_registers, :text_columns, :ruling, :rubrication,
:transcription, :transcription_expanded, :transcription_translation, :identity,
show_attributes :id, :name, :visual_context_id, :notes, :number_sewing_supports, :number_fastenings,
:inscriptions_on_binding, :inscription_text, :endband_present, :uncut_fore_edges, :fore_edge_text,
:bookmarks_registers, :text_columns, :ruling, :rubrication, :transcription, :transcription_expanded,
:transcription_translation, :identity,
qualifications: QualificationsSerializer, actions: [:id, :document_id, :notes,
qualifications: QualificationsSerializer]

Expand Down
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": {
"@babel/eslint-parser": "^7.21.3",
"@babel/runtime": "^7.22.3",
"@performant-software/semantic-components": "^2.2.17-beta.0",
"@performant-software/shared-components": "^2.2.17-beta.0",
"@performant-software/semantic-components": "^2.2.17-beta.2",
"@performant-software/shared-components": "^2.2.17-beta.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand Down
7 changes: 0 additions & 7 deletions client/src/components/SearchFacets.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,6 @@ const SearchFacets = (props: any) => {
toggleable
useRefinementList={useRefinementList}
/>
<FacetToggle
attribute='sewing_supports_visible_facet'
defaultActive={false}
ref={setRef}
title={getLabel('sewing_supports_visible_facet')}
useToggleRefinement={useToggleRefinement}
/>
<FacetSlider
attribute='number_sewing_supports_facet'
defaultActive={false}
Expand Down
4 changes: 0 additions & 4 deletions client/src/pages/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ const Document = () => {
object: 'Document',
group: 'Binding Color'
}
}, {
name: 'sewing_supports_visible',
label: t('Document.labels.sewingSupportsVisible'),
renderValue: () => <BooleanIcon value={item.sewing_supports_visible} />
}, {
name: 'number_sewing_supports',
label: t('Document.labels.numberSewingSupports')
Expand Down
13 changes: 4 additions & 9 deletions client/src/pages/admin/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,24 +188,18 @@ const Document = (props: Props) => {
multiple
object='Document'
/>
<Form.Checkbox
checked={props.item.sewing_supports_visible}
error={props.isError('sewing_supports_visible')}
label={props.t('Document.labels.sewingSupportsVisible')}
onChange={props.onCheckboxInputChange.bind(this, 'sewing_supports_visible')}
required={props.isRequired('sewing_supports_visible')}
toggle
/>
<Form.Input
error={props.isError('number_sewing_supports')}
label={props.t('Document.labels.numberSewingSupports')}
required={props.isRequired('number_sewing_supports')}
>
<Dropdown
defaultValue={0}
fluid
onChange={props.onTextInputChange.bind(this, 'number_sewing_supports')}
options={zeroToTenRangeOptionsList}
selection
value={props.item.number_sewing_supports || ''}
value={props.item.number_sewing_supports}
/>
</Form.Input>
<ValueListDropdown
Expand Down Expand Up @@ -409,6 +403,7 @@ const Document = (props: Props) => {
>
<Dropdown
defaultValue={0}
fluid
onChange={props.onTextInputChange.bind(this, 'text_columns')}
options={zeroToTenRangeOptionsList}
selection
Expand Down
1 change: 0 additions & 1 deletion client/src/transforms/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Document extends FormDataTransform {
'visual_context_id',
'name',
'notes',
'sewing_supports_visible',
'number_sewing_supports',
'number_fastenings',
'inscriptions_on_binding',
Expand Down
1 change: 0 additions & 1 deletion client/src/types/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export type Document = {
artwork_id: number,
name: string,
notes: string,
sewing_supports_visible: boolean,
number_sewing_supports: number,
number_fastenings: number,
location_of_fastenings: string,
Expand Down
16 changes: 8 additions & 8 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2549,10 +2549,10 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@performant-software/semantic-components@^2.2.17-beta.0":
version "2.2.17-beta.0"
resolved "https://registry.yarnpkg.com/@performant-software/semantic-components/-/semantic-components-2.2.17-beta.0.tgz#1a7102924f1da157ea1e4403366c53386e5cc3db"
integrity sha512-S76jbv7CZL6Kcvltr610yd0xV2Mq/Xaudylt6En19RJpqa0Cz0Sm04ETqx2a2kVlCt5xGHtKgRnhPOinaIsshA==
"@performant-software/semantic-components@^2.2.17-beta.2":
version "2.2.17-beta.2"
resolved "https://registry.yarnpkg.com/@performant-software/semantic-components/-/semantic-components-2.2.17-beta.2.tgz#d1d11a19bce3c88ccca50ac6507358f458360000"
integrity sha512-tIrfMKisI1b0XMgpjUeYbBrF+0/I4d5oxuUGuH7qcwyXiXPH7s3S7f5vx/FRf0SoqAaxcJHVU8RBF7P6fpoORQ==
dependencies:
"@react-google-maps/api" "^2.8.1"
axios "^0.26.1"
Expand All @@ -2570,10 +2570,10 @@
zotero-api-client "^0.40.0"
zotero-translation-client "^5.0.1"

"@performant-software/shared-components@^2.2.17-beta.0":
version "2.2.17-beta.0"
resolved "https://registry.yarnpkg.com/@performant-software/shared-components/-/shared-components-2.2.17-beta.0.tgz#ce0637ca07a5c828dcc29751816e0081abe884ad"
integrity sha512-Q/+/ALS9TWcOuycBDRpt4sta8+tyDWzAzhBi5IEZq+r/urooK1VybrEEP6hcUi+ta1qOcDT0UewscJb0pAf03g==
"@performant-software/shared-components@^2.2.17-beta.2":
version "2.2.17-beta.2"
resolved "https://registry.yarnpkg.com/@performant-software/shared-components/-/shared-components-2.2.17-beta.2.tgz#e82d33b169f9fc09d8359f18a707b3f3c9afa7bb"
integrity sha512-dFAk0ABAXdjm+OWm7qGRkWo/e4kdo6Idv4u09KLfas3m4kKZZ/o4XzAffgA9g1fM9/CRz7Wuk5iJWzO+viRQPw==
dependencies:
"@react-google-maps/api" "^2.8.1"
axios "^0.26.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class ResetDocumentTextColumns < ActiveRecord::Migration[7.0]
class ResetDocumentsTextColumns < ActiveRecord::Migration[7.0]
def up
execute <<-SQL.squish
UPDATE documents
Expand Down
16 changes: 16 additions & 0 deletions db/data/20241127121425_reset_documents_number_sewing_supports.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

class ResetDocumentsNumberSewingSupports < ActiveRecord::Migration[7.0]
def up
execute <<-SQL.squish
UPDATE documents
SET number_sewing_supports = 0
WHERE number_sewing_supports IS NULL;
SQL

end

def down
raise ActiveRecord::IrreversibleMigration
end
end
2 changes: 1 addition & 1 deletion db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DataMigrate::Data.define(version: 20241127010852)
DataMigrate::Data.define(version: 20241127121425)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveDocumentsSewingSupportsVisible < ActiveRecord::Migration[7.0]
def change
remove_column :documents, :sewing_supports_visible
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeDocumentsNumberSewingSupportsDefaultValue < ActiveRecord::Migration[7.0]
def change
change_column :documents, :number_sewing_supports, :integer, null: false, default: 0
end
end
5 changes: 2 additions & 3 deletions 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_11_27_011227) do
ActiveRecord::Schema[7.0].define(version: 2024_11_27_121542) 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 @@ -112,8 +112,7 @@
t.bigint "visual_context_id", null: false
t.string "name"
t.string "notes"
t.boolean "sewing_supports_visible", default: false
t.integer "number_sewing_supports"
t.integer "number_sewing_supports", default: 0, null: false
t.integer "number_fastenings"
t.boolean "inscriptions_on_binding", default: false, null: false
t.text "inscription_text"
Expand Down

0 comments on commit 8a47b77

Please sign in to comment.