From e8388b979c5c4bc9343da45be4cee9233c1e015b Mon Sep 17 00:00:00 2001 From: David Ashby Date: Sat, 7 May 2022 15:35:07 -0400 Subject: [PATCH] remove onloan column --- database/migrations/mysql/02-remove-onloan.sql | 1 + database/mysql.go | 11 ++++------- frontend/files/app.js | 7 ++----- frontend/files/records/style.css | 12 ------------ frontend/files/style.css | 12 ------------ importer/csv.go | 1 - media/media.go | 1 - ui/ui.go | 1 - 8 files changed, 7 insertions(+), 39 deletions(-) create mode 100644 database/migrations/mysql/02-remove-onloan.sql diff --git a/database/migrations/mysql/02-remove-onloan.sql b/database/migrations/mysql/02-remove-onloan.sql new file mode 100644 index 0000000..b6b931e --- /dev/null +++ b/database/migrations/mysql/02-remove-onloan.sql @@ -0,0 +1 @@ +ALTER TABLE books DROP COLUMN onloan; \ No newline at end of file diff --git a/database/mysql.go b/database/mysql.go index 0bd2a40..350dc90 100644 --- a/database/mysql.go +++ b/database/mysql.go @@ -155,7 +155,7 @@ func (m *MySQL) GetAllBooks(ctx context.Context) ([]media.Book, error) { allBooksQuery := fmt.Sprintf(`SELECT id, title, authors, sortauthor, isbn10, isbn13, format, genre, publisher, series, volume, year, signed, - description, notes, onloan, coverurl + description, notes, coverurl FROM %s`, m.tableName) books := []media.Book{} @@ -174,7 +174,7 @@ func (m *MySQL) GetAllBooks(ctx context.Context) ([]media.Book, error) { &b.Format, &b.Genre, &b.Publisher, &b.Series, &b.Volume, &b.Year, &b.Signed, &b.Description, &b.Notes, - &b.OnLoan, &b.CoverURL) + &b.CoverURL) if err != nil { return nil, err } @@ -192,9 +192,9 @@ func (m *MySQL) AddBook(ctx context.Context, b *media.Book) error { res, err := m.connection.ExecContext(ctx, ` INSERT INTO `+m.tableName+` - (title, authors, sortauthor, isbn10, isbn13, format, genre, publisher, series, volume, year, signed, description, notes, onloan, coverurl) + (title, authors, sortauthor, isbn10, isbn13, format, genre, publisher, series, volume, year, signed, description, notes, coverurl) VALUES - (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, + (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, b.Title, strings.Join(b.Authors, ";"), b.SortAuthor, @@ -209,7 +209,6 @@ func (m *MySQL) AddBook(ctx context.Context, b *media.Book) error { b.Signed, b.Description, b.Notes, - b.OnLoan, b.CoverURL, ) if err != nil { @@ -250,7 +249,6 @@ func (m *MySQL) UpdateBook(ctx context.Context, old, new *media.Book) error { signed=? description=? notes=? - onloan=? coverurl=? WHERE id=?`, new.Title, @@ -267,7 +265,6 @@ func (m *MySQL) UpdateBook(ctx context.Context, old, new *media.Book) error { new.Signed, new.Description, new.Notes, - new.OnLoan, new.CoverURL, old.ID) if err != nil { diff --git a/frontend/files/app.js b/frontend/files/app.js index f218913..bfe23a0 100644 --- a/frontend/files/app.js +++ b/frontend/files/app.js @@ -127,7 +127,6 @@ function BookTemplate({ description, format, notes, - onLoan, publisher, series, signed, @@ -136,7 +135,7 @@ function BookTemplate({ year, }) { return `${coverURL ? `` : ""} -

${title}

+

${title}

${authors}

${isbn13}
${publisher}, ${year}
@@ -147,7 +146,6 @@ function BookTemplate({ } ${signed ? "Signed by the author ✒
" : ""} ${format} - ${onLoan ? `

On loan to ${onLoan}

` : ""}

${description}

${notes ? `Notes:

${notes}

` : ""} @@ -157,14 +155,13 @@ function BookTemplate({ function TableRowTemplate({ "isbn-13": isbn13, authors, - onLoan, publisher, rowNumber, signed, title, year, }) { - return ` + return ` ${title} ${ signed ? '︎' : "" diff --git a/frontend/files/records/style.css b/frontend/files/records/style.css index e4cb1ea..c516cd2 100644 --- a/frontend/files/records/style.css +++ b/frontend/files/records/style.css @@ -243,10 +243,6 @@ body { cursor: pointer; } -.recordTable .onLoan { - color: #bbb; -} - .recordTable .tRow .name { font-style: italic; max-width: 600px; @@ -274,11 +270,3 @@ body { #current .description p { padding: 20px 0; } - -#current h1.onLoan { - color: #bbb; -} - -#current h2.onLoan { - font-weight: bold; -} diff --git a/frontend/files/style.css b/frontend/files/style.css index 7e06c43..535a6b1 100644 --- a/frontend/files/style.css +++ b/frontend/files/style.css @@ -243,10 +243,6 @@ body { cursor: pointer; } -.bookTable .onLoan { - color: #bbb; -} - .bookTable .tRow .title { font-style: italic; max-width: 600px; @@ -274,11 +270,3 @@ body { #current .description p { padding: 20px 0; } - -#current h1.onLoan { - color: #bbb; -} - -#current h2.onLoan { - font-weight: bold; -} diff --git a/importer/csv.go b/importer/csv.go index 0032815..edfcfad 100644 --- a/importer/csv.go +++ b/importer/csv.go @@ -40,7 +40,6 @@ func CSVToBooks(r io.Reader) ([]media.Book, error) { Signed: row[hmap["signed"]] == "yes", // convert from known string to bool Description: row[hmap["description"]], Notes: row[hmap["notes"]], - OnLoan: row[hmap["onloan"]], CoverURL: row[hmap["coverurl"]], } books = append(books, b) diff --git a/media/media.go b/media/media.go index 1b09442..b0781b0 100644 --- a/media/media.go +++ b/media/media.go @@ -16,7 +16,6 @@ type Book struct { Signed bool `json:"signed"` Description string `json:"description"` Notes string `json:"notes"` - OnLoan string `json:"onLoan"` CoverURL string `json:"coverURL"` } diff --git a/ui/ui.go b/ui/ui.go index 4c99520..70f3f0f 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -404,7 +404,6 @@ func (l *BookDetails) Draw(s tcell.Screen) { {"Volume", l.book.Volume}, {"Year", l.book.Year}, {"Signed", strconv.FormatBool(l.book.Signed)}, - {"On Loan", l.book.OnLoan}, {"Cover URL", l.book.CoverURL}, {"Notes", l.book.Notes}, {"Description", l.book.Description},