merge tmp to main
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,7 +1,10 @@
|
|||||||
app
|
app
|
||||||
|
mikayla-moving
|
||||||
|
|
||||||
|
tmp
|
||||||
|
output.css
|
||||||
|
|
||||||
*.swp
|
*.swp
|
||||||
*.test
|
*.test
|
||||||
*.out
|
*.out
|
||||||
tmp
|
*.db
|
||||||
output.css
|
|
||||||
example.db
|
|
||||||
|
|||||||
11
Makefile
11
Makefile
@@ -31,7 +31,16 @@ test:
|
|||||||
## build: build a binary
|
## build: build a binary
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: test
|
build: test
|
||||||
go build -o ./app -v
|
sudo rm -f mikayla-moving
|
||||||
|
go build -o ./mikayla-moving -v
|
||||||
|
sudo cp mikayla-moving /usr/bin/mikayla-moving
|
||||||
|
|
||||||
|
# restart: rebuild and restart the systemd service running the project
|
||||||
|
.PHONY: restart
|
||||||
|
restart:
|
||||||
|
sudo systemctl stop mikayla-moving
|
||||||
|
make build
|
||||||
|
sudo systemctl restart mikayla-moving
|
||||||
|
|
||||||
## docker-build: build project into a docker container image
|
## docker-build: build project into a docker container image
|
||||||
.PHONY: docker-build
|
.PHONY: docker-build
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
@tailwind base;
|
|
||||||
@tailwind components;
|
|
||||||
@tailwind utilities;
|
|
||||||
984
css/output.css
984
css/output.css
@@ -1,984 +0,0 @@
|
|||||||
/*
|
|
||||||
! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
|
|
||||||
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
|
|
||||||
*/
|
|
||||||
|
|
||||||
*,
|
|
||||||
::before,
|
|
||||||
::after {
|
|
||||||
box-sizing: border-box;
|
|
||||||
/* 1 */
|
|
||||||
border-width: 0;
|
|
||||||
/* 2 */
|
|
||||||
border-style: solid;
|
|
||||||
/* 2 */
|
|
||||||
border-color: #e5e7eb;
|
|
||||||
/* 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
::before,
|
|
||||||
::after {
|
|
||||||
--tw-content: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Use a consistent sensible line-height in all browsers.
|
|
||||||
2. Prevent adjustments of font size after orientation changes in iOS.
|
|
||||||
3. Use a more readable tab size.
|
|
||||||
4. Use the user's configured `sans` font-family by default.
|
|
||||||
5. Use the user's configured `sans` font-feature-settings by default.
|
|
||||||
6. Use the user's configured `sans` font-variation-settings by default.
|
|
||||||
*/
|
|
||||||
|
|
||||||
html {
|
|
||||||
line-height: 1.5;
|
|
||||||
/* 1 */
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
/* 2 */
|
|
||||||
-moz-tab-size: 4;
|
|
||||||
/* 3 */
|
|
||||||
-o-tab-size: 4;
|
|
||||||
tab-size: 4;
|
|
||||||
/* 3 */
|
|
||||||
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
||||||
/* 4 */
|
|
||||||
font-feature-settings: normal;
|
|
||||||
/* 5 */
|
|
||||||
font-variation-settings: normal;
|
|
||||||
/* 6 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Remove the margin in all browsers.
|
|
||||||
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
|
|
||||||
*/
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
/* 1 */
|
|
||||||
line-height: inherit;
|
|
||||||
/* 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Add the correct height in Firefox.
|
|
||||||
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
|
|
||||||
3. Ensure horizontal rules are visible by default.
|
|
||||||
*/
|
|
||||||
|
|
||||||
hr {
|
|
||||||
height: 0;
|
|
||||||
/* 1 */
|
|
||||||
color: inherit;
|
|
||||||
/* 2 */
|
|
||||||
border-top-width: 1px;
|
|
||||||
/* 3 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Add the correct text decoration in Chrome, Edge, and Safari.
|
|
||||||
*/
|
|
||||||
|
|
||||||
abbr:where([title]) {
|
|
||||||
-webkit-text-decoration: underline dotted;
|
|
||||||
text-decoration: underline dotted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Remove the default font size and weight for headings.
|
|
||||||
*/
|
|
||||||
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
h4,
|
|
||||||
h5,
|
|
||||||
h6 {
|
|
||||||
font-size: inherit;
|
|
||||||
font-weight: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Reset links to optimize for opt-in styling instead of opt-out.
|
|
||||||
*/
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Add the correct font weight in Edge and Safari.
|
|
||||||
*/
|
|
||||||
|
|
||||||
b,
|
|
||||||
strong {
|
|
||||||
font-weight: bolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Use the user's configured `mono` font family by default.
|
|
||||||
2. Correct the odd `em` font sizing in all browsers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
code,
|
|
||||||
kbd,
|
|
||||||
samp,
|
|
||||||
pre {
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
||||||
/* 1 */
|
|
||||||
font-size: 1em;
|
|
||||||
/* 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Add the correct font size in all browsers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
small {
|
|
||||||
font-size: 80%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
sub,
|
|
||||||
sup {
|
|
||||||
font-size: 75%;
|
|
||||||
line-height: 0;
|
|
||||||
position: relative;
|
|
||||||
vertical-align: baseline;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub {
|
|
||||||
bottom: -0.25em;
|
|
||||||
}
|
|
||||||
|
|
||||||
sup {
|
|
||||||
top: -0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
|
|
||||||
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
|
|
||||||
3. Remove gaps between table borders by default.
|
|
||||||
*/
|
|
||||||
|
|
||||||
table {
|
|
||||||
text-indent: 0;
|
|
||||||
/* 1 */
|
|
||||||
border-color: inherit;
|
|
||||||
/* 2 */
|
|
||||||
border-collapse: collapse;
|
|
||||||
/* 3 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Change the font styles in all browsers.
|
|
||||||
2. Remove the margin in Firefox and Safari.
|
|
||||||
3. Remove default padding in all browsers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
button,
|
|
||||||
input,
|
|
||||||
optgroup,
|
|
||||||
select,
|
|
||||||
textarea {
|
|
||||||
font-family: inherit;
|
|
||||||
/* 1 */
|
|
||||||
font-feature-settings: inherit;
|
|
||||||
/* 1 */
|
|
||||||
font-variation-settings: inherit;
|
|
||||||
/* 1 */
|
|
||||||
font-size: 100%;
|
|
||||||
/* 1 */
|
|
||||||
font-weight: inherit;
|
|
||||||
/* 1 */
|
|
||||||
line-height: inherit;
|
|
||||||
/* 1 */
|
|
||||||
color: inherit;
|
|
||||||
/* 1 */
|
|
||||||
margin: 0;
|
|
||||||
/* 2 */
|
|
||||||
padding: 0;
|
|
||||||
/* 3 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Remove the inheritance of text transform in Edge and Firefox.
|
|
||||||
*/
|
|
||||||
|
|
||||||
button,
|
|
||||||
select {
|
|
||||||
text-transform: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Correct the inability to style clickable types in iOS and Safari.
|
|
||||||
2. Remove default button styles.
|
|
||||||
*/
|
|
||||||
|
|
||||||
button,
|
|
||||||
[type='button'],
|
|
||||||
[type='reset'],
|
|
||||||
[type='submit'] {
|
|
||||||
-webkit-appearance: button;
|
|
||||||
/* 1 */
|
|
||||||
background-color: transparent;
|
|
||||||
/* 2 */
|
|
||||||
background-image: none;
|
|
||||||
/* 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Use the modern Firefox focus style for all focusable elements.
|
|
||||||
*/
|
|
||||||
|
|
||||||
:-moz-focusring {
|
|
||||||
outline: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
|
|
||||||
*/
|
|
||||||
|
|
||||||
:-moz-ui-invalid {
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Add the correct vertical alignment in Chrome and Firefox.
|
|
||||||
*/
|
|
||||||
|
|
||||||
progress {
|
|
||||||
vertical-align: baseline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Correct the cursor style of increment and decrement buttons in Safari.
|
|
||||||
*/
|
|
||||||
|
|
||||||
::-webkit-inner-spin-button,
|
|
||||||
::-webkit-outer-spin-button {
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Correct the odd appearance in Chrome and Safari.
|
|
||||||
2. Correct the outline style in Safari.
|
|
||||||
*/
|
|
||||||
|
|
||||||
[type='search'] {
|
|
||||||
-webkit-appearance: textfield;
|
|
||||||
/* 1 */
|
|
||||||
outline-offset: -2px;
|
|
||||||
/* 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Remove the inner padding in Chrome and Safari on macOS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
::-webkit-search-decoration {
|
|
||||||
-webkit-appearance: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Correct the inability to style clickable types in iOS and Safari.
|
|
||||||
2. Change font properties to `inherit` in Safari.
|
|
||||||
*/
|
|
||||||
|
|
||||||
::-webkit-file-upload-button {
|
|
||||||
-webkit-appearance: button;
|
|
||||||
/* 1 */
|
|
||||||
font: inherit;
|
|
||||||
/* 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Add the correct display in Chrome and Safari.
|
|
||||||
*/
|
|
||||||
|
|
||||||
summary {
|
|
||||||
display: list-item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Removes the default spacing and border for appropriate elements.
|
|
||||||
*/
|
|
||||||
|
|
||||||
blockquote,
|
|
||||||
dl,
|
|
||||||
dd,
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
h4,
|
|
||||||
h5,
|
|
||||||
h6,
|
|
||||||
hr,
|
|
||||||
figure,
|
|
||||||
p,
|
|
||||||
pre {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldset {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
legend {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol,
|
|
||||||
ul,
|
|
||||||
menu {
|
|
||||||
list-style: none;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Reset default styling for dialogs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
dialog {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Prevent resizing textareas horizontally by default.
|
|
||||||
*/
|
|
||||||
|
|
||||||
textarea {
|
|
||||||
resize: vertical;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
|
|
||||||
2. Set the default placeholder color to the user's configured gray 400 color.
|
|
||||||
*/
|
|
||||||
|
|
||||||
input::-moz-placeholder, textarea::-moz-placeholder {
|
|
||||||
opacity: 1;
|
|
||||||
/* 1 */
|
|
||||||
color: #9ca3af;
|
|
||||||
/* 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
input::placeholder,
|
|
||||||
textarea::placeholder {
|
|
||||||
opacity: 1;
|
|
||||||
/* 1 */
|
|
||||||
color: #9ca3af;
|
|
||||||
/* 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Set the default cursor for buttons.
|
|
||||||
*/
|
|
||||||
|
|
||||||
button,
|
|
||||||
[role="button"] {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Make sure disabled buttons don't get the pointer cursor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
:disabled {
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
|
|
||||||
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
|
|
||||||
This can trigger a poorly considered lint error in some tools but is included by design.
|
|
||||||
*/
|
|
||||||
|
|
||||||
img,
|
|
||||||
svg,
|
|
||||||
video,
|
|
||||||
canvas,
|
|
||||||
audio,
|
|
||||||
iframe,
|
|
||||||
embed,
|
|
||||||
object {
|
|
||||||
display: block;
|
|
||||||
/* 1 */
|
|
||||||
vertical-align: middle;
|
|
||||||
/* 2 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
|
|
||||||
*/
|
|
||||||
|
|
||||||
img,
|
|
||||||
video {
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make elements with the HTML hidden attribute stay hidden by default */
|
|
||||||
|
|
||||||
[hidden] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='text'],[type='email'],[type='url'],[type='password'],[type='number'],[type='date'],[type='datetime-local'],[type='month'],[type='search'],[type='tel'],[type='time'],[type='week'],[multiple],textarea,select {
|
|
||||||
-webkit-appearance: none;
|
|
||||||
-moz-appearance: none;
|
|
||||||
appearance: none;
|
|
||||||
background-color: #fff;
|
|
||||||
border-color: #6b7280;
|
|
||||||
border-width: 1px;
|
|
||||||
border-radius: 0px;
|
|
||||||
padding-top: 0.5rem;
|
|
||||||
padding-right: 0.75rem;
|
|
||||||
padding-bottom: 0.5rem;
|
|
||||||
padding-left: 0.75rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
line-height: 1.5rem;
|
|
||||||
--tw-shadow: 0 0 #0000;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='text']:focus, [type='email']:focus, [type='url']:focus, [type='password']:focus, [type='number']:focus, [type='date']:focus, [type='datetime-local']:focus, [type='month']:focus, [type='search']:focus, [type='tel']:focus, [type='time']:focus, [type='week']:focus, [multiple]:focus, textarea:focus, select:focus {
|
|
||||||
outline: 2px solid transparent;
|
|
||||||
outline-offset: 2px;
|
|
||||||
--tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
|
|
||||||
--tw-ring-offset-width: 0px;
|
|
||||||
--tw-ring-offset-color: #fff;
|
|
||||||
--tw-ring-color: #2563eb;
|
|
||||||
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
||||||
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
||||||
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
||||||
border-color: #2563eb;
|
|
||||||
}
|
|
||||||
|
|
||||||
input::-moz-placeholder, textarea::-moz-placeholder {
|
|
||||||
color: #6b7280;
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
input::placeholder,textarea::placeholder {
|
|
||||||
color: #6b7280;
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-datetime-edit-fields-wrapper {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-date-and-time-value {
|
|
||||||
min-height: 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-datetime-edit,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-meridiem-field {
|
|
||||||
padding-top: 0;
|
|
||||||
padding-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
select {
|
|
||||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
|
|
||||||
background-position: right 0.5rem center;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-size: 1.5em 1.5em;
|
|
||||||
padding-right: 2.5rem;
|
|
||||||
-webkit-print-color-adjust: exact;
|
|
||||||
print-color-adjust: exact;
|
|
||||||
}
|
|
||||||
|
|
||||||
[multiple] {
|
|
||||||
background-image: initial;
|
|
||||||
background-position: initial;
|
|
||||||
background-repeat: unset;
|
|
||||||
background-size: initial;
|
|
||||||
padding-right: 0.75rem;
|
|
||||||
-webkit-print-color-adjust: unset;
|
|
||||||
print-color-adjust: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='checkbox'],[type='radio'] {
|
|
||||||
-webkit-appearance: none;
|
|
||||||
-moz-appearance: none;
|
|
||||||
appearance: none;
|
|
||||||
padding: 0;
|
|
||||||
-webkit-print-color-adjust: exact;
|
|
||||||
print-color-adjust: exact;
|
|
||||||
display: inline-block;
|
|
||||||
vertical-align: middle;
|
|
||||||
background-origin: border-box;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
user-select: none;
|
|
||||||
flex-shrink: 0;
|
|
||||||
height: 1rem;
|
|
||||||
width: 1rem;
|
|
||||||
color: #2563eb;
|
|
||||||
background-color: #fff;
|
|
||||||
border-color: #6b7280;
|
|
||||||
border-width: 1px;
|
|
||||||
--tw-shadow: 0 0 #0000;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='checkbox'] {
|
|
||||||
border-radius: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='radio'] {
|
|
||||||
border-radius: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='checkbox']:focus,[type='radio']:focus {
|
|
||||||
outline: 2px solid transparent;
|
|
||||||
outline-offset: 2px;
|
|
||||||
--tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
|
|
||||||
--tw-ring-offset-width: 2px;
|
|
||||||
--tw-ring-offset-color: #fff;
|
|
||||||
--tw-ring-color: #2563eb;
|
|
||||||
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
||||||
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
||||||
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='checkbox']:checked,[type='radio']:checked {
|
|
||||||
border-color: transparent;
|
|
||||||
background-color: currentColor;
|
|
||||||
background-size: 100% 100%;
|
|
||||||
background-position: center;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='checkbox']:checked {
|
|
||||||
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='radio']:checked {
|
|
||||||
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e");
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='checkbox']:checked:hover,[type='checkbox']:checked:focus,[type='radio']:checked:hover,[type='radio']:checked:focus {
|
|
||||||
border-color: transparent;
|
|
||||||
background-color: currentColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='checkbox']:indeterminate {
|
|
||||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e");
|
|
||||||
border-color: transparent;
|
|
||||||
background-color: currentColor;
|
|
||||||
background-size: 100% 100%;
|
|
||||||
background-position: center;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='checkbox']:indeterminate:hover,[type='checkbox']:indeterminate:focus {
|
|
||||||
border-color: transparent;
|
|
||||||
background-color: currentColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='file'] {
|
|
||||||
background: unset;
|
|
||||||
border-color: inherit;
|
|
||||||
border-width: 0;
|
|
||||||
border-radius: 0;
|
|
||||||
padding: 0;
|
|
||||||
font-size: unset;
|
|
||||||
line-height: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
[type='file']:focus {
|
|
||||||
outline: 1px solid ButtonText;
|
|
||||||
outline: 1px auto -webkit-focus-ring-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
*, ::before, ::after {
|
|
||||||
--tw-border-spacing-x: 0;
|
|
||||||
--tw-border-spacing-y: 0;
|
|
||||||
--tw-translate-x: 0;
|
|
||||||
--tw-translate-y: 0;
|
|
||||||
--tw-rotate: 0;
|
|
||||||
--tw-skew-x: 0;
|
|
||||||
--tw-skew-y: 0;
|
|
||||||
--tw-scale-x: 1;
|
|
||||||
--tw-scale-y: 1;
|
|
||||||
--tw-pan-x: ;
|
|
||||||
--tw-pan-y: ;
|
|
||||||
--tw-pinch-zoom: ;
|
|
||||||
--tw-scroll-snap-strictness: proximity;
|
|
||||||
--tw-gradient-from-position: ;
|
|
||||||
--tw-gradient-via-position: ;
|
|
||||||
--tw-gradient-to-position: ;
|
|
||||||
--tw-ordinal: ;
|
|
||||||
--tw-slashed-zero: ;
|
|
||||||
--tw-numeric-figure: ;
|
|
||||||
--tw-numeric-spacing: ;
|
|
||||||
--tw-numeric-fraction: ;
|
|
||||||
--tw-ring-inset: ;
|
|
||||||
--tw-ring-offset-width: 0px;
|
|
||||||
--tw-ring-offset-color: #fff;
|
|
||||||
--tw-ring-color: rgb(59 130 246 / 0.5);
|
|
||||||
--tw-ring-offset-shadow: 0 0 #0000;
|
|
||||||
--tw-ring-shadow: 0 0 #0000;
|
|
||||||
--tw-shadow: 0 0 #0000;
|
|
||||||
--tw-shadow-colored: 0 0 #0000;
|
|
||||||
--tw-blur: ;
|
|
||||||
--tw-brightness: ;
|
|
||||||
--tw-contrast: ;
|
|
||||||
--tw-grayscale: ;
|
|
||||||
--tw-hue-rotate: ;
|
|
||||||
--tw-invert: ;
|
|
||||||
--tw-saturate: ;
|
|
||||||
--tw-sepia: ;
|
|
||||||
--tw-drop-shadow: ;
|
|
||||||
--tw-backdrop-blur: ;
|
|
||||||
--tw-backdrop-brightness: ;
|
|
||||||
--tw-backdrop-contrast: ;
|
|
||||||
--tw-backdrop-grayscale: ;
|
|
||||||
--tw-backdrop-hue-rotate: ;
|
|
||||||
--tw-backdrop-invert: ;
|
|
||||||
--tw-backdrop-opacity: ;
|
|
||||||
--tw-backdrop-saturate: ;
|
|
||||||
--tw-backdrop-sepia: ;
|
|
||||||
}
|
|
||||||
|
|
||||||
::backdrop {
|
|
||||||
--tw-border-spacing-x: 0;
|
|
||||||
--tw-border-spacing-y: 0;
|
|
||||||
--tw-translate-x: 0;
|
|
||||||
--tw-translate-y: 0;
|
|
||||||
--tw-rotate: 0;
|
|
||||||
--tw-skew-x: 0;
|
|
||||||
--tw-skew-y: 0;
|
|
||||||
--tw-scale-x: 1;
|
|
||||||
--tw-scale-y: 1;
|
|
||||||
--tw-pan-x: ;
|
|
||||||
--tw-pan-y: ;
|
|
||||||
--tw-pinch-zoom: ;
|
|
||||||
--tw-scroll-snap-strictness: proximity;
|
|
||||||
--tw-gradient-from-position: ;
|
|
||||||
--tw-gradient-via-position: ;
|
|
||||||
--tw-gradient-to-position: ;
|
|
||||||
--tw-ordinal: ;
|
|
||||||
--tw-slashed-zero: ;
|
|
||||||
--tw-numeric-figure: ;
|
|
||||||
--tw-numeric-spacing: ;
|
|
||||||
--tw-numeric-fraction: ;
|
|
||||||
--tw-ring-inset: ;
|
|
||||||
--tw-ring-offset-width: 0px;
|
|
||||||
--tw-ring-offset-color: #fff;
|
|
||||||
--tw-ring-color: rgb(59 130 246 / 0.5);
|
|
||||||
--tw-ring-offset-shadow: 0 0 #0000;
|
|
||||||
--tw-ring-shadow: 0 0 #0000;
|
|
||||||
--tw-shadow: 0 0 #0000;
|
|
||||||
--tw-shadow-colored: 0 0 #0000;
|
|
||||||
--tw-blur: ;
|
|
||||||
--tw-brightness: ;
|
|
||||||
--tw-contrast: ;
|
|
||||||
--tw-grayscale: ;
|
|
||||||
--tw-hue-rotate: ;
|
|
||||||
--tw-invert: ;
|
|
||||||
--tw-saturate: ;
|
|
||||||
--tw-sepia: ;
|
|
||||||
--tw-drop-shadow: ;
|
|
||||||
--tw-backdrop-blur: ;
|
|
||||||
--tw-backdrop-brightness: ;
|
|
||||||
--tw-backdrop-contrast: ;
|
|
||||||
--tw-backdrop-grayscale: ;
|
|
||||||
--tw-backdrop-hue-rotate: ;
|
|
||||||
--tw-backdrop-invert: ;
|
|
||||||
--tw-backdrop-opacity: ;
|
|
||||||
--tw-backdrop-saturate: ;
|
|
||||||
--tw-backdrop-sepia: ;
|
|
||||||
}
|
|
||||||
|
|
||||||
.m-2 {
|
|
||||||
margin: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inline-block {
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flex {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inline-flex {
|
|
||||||
display: inline-flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table {
|
|
||||||
display: table;
|
|
||||||
}
|
|
||||||
|
|
||||||
.h-8 {
|
|
||||||
height: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-full {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.min-w-full {
|
|
||||||
min-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.appearance-none {
|
|
||||||
-webkit-appearance: none;
|
|
||||||
-moz-appearance: none;
|
|
||||||
appearance: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flex-col {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.items-center {
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.justify-end {
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.overflow-hidden {
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.overflow-x-auto {
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.whitespace-nowrap {
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rounded {
|
|
||||||
border-radius: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rounded-lg {
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border {
|
|
||||||
border-width: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-b {
|
|
||||||
border-bottom-width: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-blue-700 {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(29 78 216 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-red-700 {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(185 28 28 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.px-1 {
|
|
||||||
padding-left: 0.25rem;
|
|
||||||
padding-right: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.px-3 {
|
|
||||||
padding-left: 0.75rem;
|
|
||||||
padding-right: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.px-4 {
|
|
||||||
padding-left: 1rem;
|
|
||||||
padding-right: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.px-6 {
|
|
||||||
padding-left: 1.5rem;
|
|
||||||
padding-right: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.py-1 {
|
|
||||||
padding-top: 0.25rem;
|
|
||||||
padding-bottom: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.py-2 {
|
|
||||||
padding-top: 0.5rem;
|
|
||||||
padding-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.py-4 {
|
|
||||||
padding-top: 1rem;
|
|
||||||
padding-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-left {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-3xl {
|
|
||||||
font-size: 1.875rem;
|
|
||||||
line-height: 2.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-sm {
|
|
||||||
font-size: 0.875rem;
|
|
||||||
line-height: 1.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-xl {
|
|
||||||
font-size: 1.25rem;
|
|
||||||
line-height: 1.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.font-light {
|
|
||||||
font-weight: 300;
|
|
||||||
}
|
|
||||||
|
|
||||||
.font-medium {
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.leading-tight {
|
|
||||||
line-height: 1.25;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-blue-100 {
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: rgb(219 234 254 / var(--tw-text-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-blue-700 {
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: rgb(29 78 216 / var(--tw-text-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-gray-700 {
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: rgb(55 65 81 / var(--tw-text-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-red-100 {
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: rgb(254 226 226 / var(--tw-text-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.shadow {
|
|
||||||
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
|
||||||
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
|
|
||||||
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
.transition-colors {
|
|
||||||
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
|
|
||||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
||||||
transition-duration: 150ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
.duration-150 {
|
|
||||||
transition-duration: 150ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
|
||||||
.md\:container {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 640px) {
|
|
||||||
.md\:container {
|
|
||||||
max-width: 640px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
|
||||||
.md\:container {
|
|
||||||
max-width: 768px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
|
||||||
.md\:container {
|
|
||||||
max-width: 1024px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1280px) {
|
|
||||||
.md\:container {
|
|
||||||
max-width: 1280px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1536px) {
|
|
||||||
.md\:container {
|
|
||||||
max-width: 1536px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hover\:bg-blue-800:hover {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(30 64 175 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.hover\:bg-red-800:hover {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(153 27 27 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.hover\:underline:hover {
|
|
||||||
text-decoration-line: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.focus\:outline-none:focus {
|
|
||||||
outline: 2px solid transparent;
|
|
||||||
outline-offset: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
.dark\:border-neutral-500 {
|
|
||||||
--tw-border-opacity: 1;
|
|
||||||
border-color: rgb(115 115 115 / var(--tw-border-opacity));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 640px) {
|
|
||||||
.sm\:-mx-6 {
|
|
||||||
margin-left: -1.5rem;
|
|
||||||
margin-right: -1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sm\:px-6 {
|
|
||||||
padding-left: 1.5rem;
|
|
||||||
padding-right: 1.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
|
||||||
.md\:mx-auto {
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
|
||||||
.lg\:-mx-8 {
|
|
||||||
margin-left: -2rem;
|
|
||||||
margin-right: -2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lg\:px-8 {
|
|
||||||
padding-left: 2rem;
|
|
||||||
padding-right: 2rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,46 +20,37 @@ const (
|
|||||||
Other
|
Other
|
||||||
)
|
)
|
||||||
|
|
||||||
var CategoryMap = map[Category]string{
|
// entities
|
||||||
Bedroom: "Bedroom",
|
type Item struct {
|
||||||
Bathroom: "Bathroom",
|
ID int `json:"id"`
|
||||||
Kitchen: "Kitchen",
|
Name string `json:"name"`
|
||||||
Office: "Office",
|
Notes *string `json:"notes"`
|
||||||
LivingRoom: "Living Room",
|
Description *string `json:"description"`
|
||||||
Other: "Other",
|
Stage PackingStage `json:"stage"`
|
||||||
|
Category Category `json:"category"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var PackingStageMap = map[PackingStage]string{
|
type Box struct {
|
||||||
Essentials: "Essentials",
|
ID int `json:"id"`
|
||||||
StageOne: "Stage One",
|
Name string `json:"name"`
|
||||||
StageTwo: "Stage Two",
|
Notes *string `json:"notes"`
|
||||||
StageThree: "Stage Three",
|
Description *string `json:"description"`
|
||||||
|
Stage PackingStage `json:"stage"`
|
||||||
|
Category Category `json:"category"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EntityLabel string
|
// joining tables and derivative data types
|
||||||
|
|
||||||
const (
|
|
||||||
ItemType EntityLabel = "items"
|
|
||||||
BoxType EntityLabel = "boxes"
|
|
||||||
BoxItemType EntityLabel = "box_items"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Entity struct {
|
|
||||||
ID int
|
|
||||||
EntityLabel EntityLabel
|
|
||||||
Name string
|
|
||||||
Notes *string
|
|
||||||
Description *string
|
|
||||||
Stage PackingStage
|
|
||||||
Category Category
|
|
||||||
}
|
|
||||||
|
|
||||||
type Item Entity
|
|
||||||
type Box Entity
|
|
||||||
|
|
||||||
// joins
|
|
||||||
type BoxItem struct {
|
type BoxItem struct {
|
||||||
ID int
|
ID int
|
||||||
BoxID int
|
BoxID int
|
||||||
ItemID int
|
ItemID int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BoxItemWithItemInfo struct {
|
||||||
|
ID int
|
||||||
|
Name string
|
||||||
|
Stage PackingStage
|
||||||
|
Category Category
|
||||||
|
Description *string
|
||||||
|
Notes *string
|
||||||
|
}
|
||||||
|
|||||||
309
db/sql.go
309
db/sql.go
@@ -2,33 +2,13 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateClient() (db *sql.DB, err error) {
|
func CreateClient() (db *sql.DB, err error) {
|
||||||
return sql.Open("sqlite3", "./example.db")
|
return sql.Open("sqlite3", "./example.db")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllItems() (rows *sql.Rows, err error) {
|
func GetAllItems() (result []Item, err error) {
|
||||||
db, err := CreateClient()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
defer db.Close()
|
|
||||||
|
|
||||||
rows, err = db.Query("SELECT * FROM items")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// fmt.Println("rows", rows)
|
|
||||||
|
|
||||||
defer rows.Close()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetAll(table EntityLabel) (rows *sql.Rows, err error) {
|
|
||||||
db, err := CreateClient()
|
db, err := CreateClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -36,16 +16,29 @@ func GetAll(table EntityLabel) (rows *sql.Rows, err error) {
|
|||||||
|
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
rows, err = db.Query("SELECT * FROM ?", table)
|
rows, err := db.Query("SELECT * FROM items")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
item := Item{}
|
||||||
|
|
||||||
|
err = rows.Scan(&item.ID, &item.Name, &item.Notes, &item.Description, &item.Stage, &item.Category)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result = append(result, item)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetByID(table EntityLabel, id int) (row *sql.Row, err error) {
|
func GetAllBoxes() (result []Box, err error) {
|
||||||
db, err := CreateClient()
|
db, err := CreateClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -53,11 +46,29 @@ func GetByID(table EntityLabel, id int) (row *sql.Row, err error) {
|
|||||||
|
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
row = db.QueryRow("SELECT * FROM ? WHERE id = ?", table, id)
|
rows, err := db.Query("SELECT * FROM boxes")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
box := Box{}
|
||||||
|
|
||||||
|
err = rows.Scan(&box.ID, &box.Name, &box.Notes, &box.Description, &box.Stage, &box.Category)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result = append(result, box)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func Put[T Entity](table EntityLabel, record Entity) (sql.Result, error) {
|
func GetAllBoxItems() ([]BoxItem, error) {
|
||||||
db, err := CreateClient()
|
db, err := CreateClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -65,18 +76,76 @@ func Put[T Entity](table EntityLabel, record Entity) (sql.Result, error) {
|
|||||||
|
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
query := `UPDATE ? SET name = ?, notes = ?, description = ?, stage = ?, category = ? WHERE id = ?`
|
rows, err := db.Query("SELECT * FROM box_items")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
result, err := db.Exec(query, table, record.Name, record.Notes, record.Description, record.Stage, record.Category, record.ID)
|
defer rows.Close()
|
||||||
|
|
||||||
|
var result []BoxItem
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
boxItem := BoxItem{}
|
||||||
|
|
||||||
|
err = rows.Scan(&boxItem.ID, &boxItem.BoxID, &boxItem.ItemID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = append(result, boxItem)
|
||||||
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func PostItem(record Item) (sql.Result, error) {
|
func GetItemByID(id int) (item Item, err error) {
|
||||||
|
db, err := CreateClient()
|
||||||
|
if err != nil {
|
||||||
|
return Item{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
row := db.QueryRow("SELECT * FROM items WHERE id = ?", id)
|
||||||
|
err = row.Scan(&item.ID, &item.Name, &item.Notes, &item.Description, &item.Stage, &item.Category)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetBoxByID(id int) (box Box, err error) {
|
||||||
|
db, err := CreateClient()
|
||||||
|
if err != nil {
|
||||||
|
return Box{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
row := db.QueryRow("SELECT * FROM boxes WHERE id = ?", id)
|
||||||
|
err = row.Scan(&box.ID, &box.Name, &box.Notes, &box.Description, &box.Stage, &box.Category)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetBoxItemByID(id int) (BoxItem, error) {
|
||||||
|
db, err := CreateClient()
|
||||||
|
if err != nil {
|
||||||
|
return BoxItem{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
row := db.QueryRow("SELECT * FROM box_items WHERE id = ?", id)
|
||||||
|
|
||||||
|
boxItem := BoxItem{}
|
||||||
|
|
||||||
|
err = row.Scan(&boxItem.ID, &boxItem.BoxID, &boxItem.ItemID)
|
||||||
|
|
||||||
|
return boxItem, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetBoxItemsByBoxID(boxID int) ([]BoxItemWithItemInfo, error) {
|
||||||
db, err := CreateClient()
|
db, err := CreateClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -84,70 +153,200 @@ func PostItem(record Item) (sql.Result, error) {
|
|||||||
|
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
|
// get all rows from box_items where boxid = boxID
|
||||||
|
// also get the item info for each item
|
||||||
|
rows, err := db.Query(
|
||||||
|
"SELECT id, items.name, items.stage, items.category, items.description, items.notes FROM boxitems JOIN items ON itemid=items.id WHERE boxid = ?",
|
||||||
|
boxID)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
result := []BoxItemWithItemInfo{}
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
boxItem := BoxItemWithItemInfo{}
|
||||||
|
if err = rows.Scan(&boxItem.ID, &boxItem.Name, &boxItem.Stage, &boxItem.Category, &boxItem.Description, &boxItem.Notes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result = append(result, boxItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func PostItem(item Item) (int64, error) {
|
||||||
|
db, err := CreateClient()
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
query := `INSERT INTO items (name, notes, description, stage, category)
|
query := `INSERT INTO items (name, notes, description, stage, category)
|
||||||
VALUES (?, ?, ?, ?, ?)`
|
VALUES (?, ?, ?, ?, ?)`
|
||||||
|
|
||||||
result, err := db.Exec(query, record.Name, record.Notes, record.Description, record.Stage, record.Category)
|
result, err := db.Exec(query, item.Name, item.Notes, item.Description, item.Stage, item.Category)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result.LastInsertId()
|
||||||
}
|
}
|
||||||
|
|
||||||
func PostBox(record Box) (sql.Result, error) {
|
func PostBox(box Box) (int64, error) {
|
||||||
db, err := CreateClient()
|
db, err := CreateClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
query := `INSERT INTO boxes (name, notes, description, stage, category)
|
query := `INSERT INTO boxes (name, notes, description, stage, category) VALUES (?, ?, ?, ?, ?)`
|
||||||
VALUES (?, ?, ?, ?, ?)`
|
|
||||||
|
|
||||||
result, err := db.Exec(query, record.Name, record.Notes, record.Description, record.Stage, record.Category)
|
result, err := db.Exec(query, box.Name, box.Notes, box.Description, box.Stage, box.Category)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result.LastInsertId()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Delete(table EntityLabel, id int) (sql.Result, error) {
|
func PostBoxItem(boxItem BoxItem) (int64, error) {
|
||||||
db, err := CreateClient()
|
db, err := CreateClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
query := `DELETE FROM ? WHERE id = ?`
|
query := `INSERT INTO box_items (boxid, item_id) VALUES (?, ?)`
|
||||||
|
|
||||||
return db.Exec(query, table, id)
|
result, err := db.Exec(query, boxItem.BoxID, boxItem.ItemID)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseItem(item *Item, scan func(dest ...any) error) (err error) {
|
return result.LastInsertId()
|
||||||
return scan(&item.ID, &item.Name, &item.Notes, &item.Description, &item.Stage, &item.Category)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseBox(box *Box, scan func(dest ...any) error) error {
|
func PutItem(item Item) (int64, error) {
|
||||||
return scan(&box.ID, &box.Name, &box.Notes, &box.Description, &box.Stage, &box.Category)
|
db, err := CreateClient()
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseEntityFromBytes(b []byte) (entity Entity, err error) {
|
defer db.Close()
|
||||||
err = json.Unmarshal(b, &entity)
|
|
||||||
return
|
query := `UPDATE items SET name = ?, notes = ?, description = ?, stage = ?, category = ? WHERE id = ?`
|
||||||
|
|
||||||
|
result, err := db.Exec(query, item.Name, item.Notes, item.Description, item.Stage, item.Category, item.ID)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseItemFromBytes(b []byte) (item Item, err error) {
|
return result.RowsAffected()
|
||||||
err = json.Unmarshal(b, &item)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseBoxFromBytes(b []byte) (box Box, err error) {
|
func PutBox(box Box) (int64, error) {
|
||||||
err = json.Unmarshal(b, &box)
|
db, err := CreateClient()
|
||||||
return
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
query := `UPDATE boxes SET name = ?, notes = ?, description = ?, stage = ?, category = ? WHERE id = ?`
|
||||||
|
|
||||||
|
result, err := db.Exec(query, box.Name, box.Notes, box.Description, box.Stage, box.Category, box.ID)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.RowsAffected()
|
||||||
|
}
|
||||||
|
|
||||||
|
func PutBoxItem(boxItem BoxItem) (int64, error) {
|
||||||
|
db, err := CreateClient()
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
query := `UPDATE box_items SET boxid = ?, item_id = ? WHERE id = ?`
|
||||||
|
|
||||||
|
result, err := db.Exec(query, boxItem.BoxID, boxItem.ItemID, boxItem.ID)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.RowsAffected()
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteItem(id int) (int64, error) {
|
||||||
|
db, err := CreateClient()
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
query := `DELETE FROM items WHERE id = ?`
|
||||||
|
|
||||||
|
result, err := db.Exec(query, id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.RowsAffected()
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteBox(id int) (int64, error) {
|
||||||
|
db, err := CreateClient()
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
query := `DELETE FROM boxes WHERE id = ?`
|
||||||
|
|
||||||
|
result, err := db.Exec(query, id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.RowsAffected()
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteBoxItem(id int) (int64, error) {
|
||||||
|
db, err := CreateClient()
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
query := `DELETE FROM box_items WHERE id = ?`
|
||||||
|
|
||||||
|
result, err := db.Exec(query, id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.RowsAffected()
|
||||||
}
|
}
|
||||||
|
|||||||
41
main.go
41
main.go
@@ -23,9 +23,6 @@ var (
|
|||||||
//go:embed all:templates/*
|
//go:embed all:templates/*
|
||||||
templateFS embed.FS
|
templateFS embed.FS
|
||||||
|
|
||||||
//go:embed css/output.css
|
|
||||||
css embed.FS
|
|
||||||
|
|
||||||
//parsed templates
|
//parsed templates
|
||||||
html *template.Template
|
html *template.Template
|
||||||
)
|
)
|
||||||
@@ -49,18 +46,38 @@ func main() {
|
|||||||
|
|
||||||
//add routes
|
//add routes
|
||||||
router := http.NewServeMux()
|
router := http.NewServeMux()
|
||||||
// router.Handle("/css/output.css", http.FileServer(http.FS(css)))
|
|
||||||
|
|
||||||
// router.Handle("/company/add", web.Action(companyAdd))
|
itemActions := routes.Items(html)
|
||||||
// router.Handle("/company/add/", web.Action(companyAdd))
|
boxActions := routes.Boxes(html)
|
||||||
|
boxItemActions := routes.BoxItems(html)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
router.Handle("/items/edit", web.Action(itemActions.Edit))
|
||||||
|
router.Handle("/items/delete", web.Action(itemActions.Delete))
|
||||||
|
router.Handle("/items/save", web.Action(itemActions.Save))
|
||||||
|
router.Handle("/items/edit/", web.Action(itemActions.Edit))
|
||||||
|
router.Handle("/items/delete/", web.Action(itemActions.Delete))
|
||||||
|
router.Handle("/items/delete/:id", web.Action(itemActions.Delete))
|
||||||
|
router.Handle("/items/save/", web.Action(itemActions.Save))
|
||||||
|
router.Handle("/items/save/:id", web.Action(itemActions.Save))
|
||||||
|
|
||||||
|
router.Handle("/items/add", web.Action(itemActions.Post))
|
||||||
|
router.Handle("/items/add/", web.Action(itemActions.Post))
|
||||||
|
|
||||||
|
router.Handle("/box-items", web.Action(boxItemActions.Get))
|
||||||
|
router.Handle("/box-items/", web.Action(boxItemActions.Get))
|
||||||
|
router.Handle("/box-items/:id", web.Action(boxItemActions.Get))
|
||||||
|
|
||||||
|
router.Handle("/items", web.Action(itemActions.Get))
|
||||||
|
router.Handle("/boxes", web.Action(boxActions.GetAll))
|
||||||
|
router.Handle("/items/", web.Action(itemActions.Get))
|
||||||
|
router.Handle("/items/:id", web.Action(itemActions.Get))
|
||||||
|
router.Handle("/boxes/", web.Action(boxActions.GetAll))
|
||||||
|
router.Handle("/boxes/:id", web.Action(boxActions.GetAll))
|
||||||
|
|
||||||
router.Handle("/", web.Action(routes.HomePage))
|
router.Handle("/", web.Action(routes.HomePage))
|
||||||
router.Handle("/items", web.Action(routes.Items(html).GetAll))
|
router.Handle("/index.html", web.Action(routes.HomePage))
|
||||||
router.Handle("/items/{id}", web.Action(routes.Items(html).GetByID))
|
|
||||||
router.Handle("/boxes", web.Action(routes.Boxes(html).GetAll))
|
|
||||||
router.Handle("/unrelated", web.Action(func(r *http.Request) *web.Response {
|
|
||||||
return web.HTML(http.StatusOK, html, "row-edit.html", nil, nil)
|
|
||||||
}))
|
|
||||||
|
|
||||||
//logging/tracing
|
//logging/tracing
|
||||||
nextRequestID := func() string {
|
nextRequestID := func() string {
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
package routes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/innocuous-symmetry/moving-mgmt/db"
|
|
||||||
"github.com/jritsema/gotoolbox/web"
|
|
||||||
)
|
|
||||||
|
|
||||||
type RouterActions struct {
|
|
||||||
GetAll func(r *http.Request) *web.Response
|
|
||||||
GetByID func(r *http.Request) *web.Response
|
|
||||||
Post func(r *http.Request) *web.Response
|
|
||||||
Put func(r *http.Request) *web.Response
|
|
||||||
Delete func(r *http.Request) *web.Response
|
|
||||||
}
|
|
||||||
|
|
||||||
type Router struct {
|
|
||||||
Entity db.EntityLabel
|
|
||||||
GetAll func(r *http.Request) *web.Response
|
|
||||||
GetByID func(r *http.Request) *web.Response
|
|
||||||
Post func(r *http.Request) *web.Response
|
|
||||||
Put func(r *http.Request) *web.Response
|
|
||||||
Delete func(r *http.Request) *web.Response
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRouter(entity db.EntityLabel, actions RouterActions) *Router {
|
|
||||||
return &Router{
|
|
||||||
Entity: entity,
|
|
||||||
GetAll: actions.GetAll,
|
|
||||||
GetByID: actions.GetByID,
|
|
||||||
Post: actions.Post,
|
|
||||||
Put: actions.Put,
|
|
||||||
Delete: actions.Delete,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
100
routes/boxItems.go
Normal file
100
routes/boxItems.go
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"html/template"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/innocuous-symmetry/moving-mgmt/db"
|
||||||
|
"github.com/jritsema/gotoolbox/web"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BoxItemActions struct {
|
||||||
|
Get func(r *http.Request) *web.Response
|
||||||
|
GetAll func(r *http.Request) *web.Response
|
||||||
|
GetByID func(r *http.Request) *web.Response
|
||||||
|
GetByBoxID func(r *http.Request) *web.Response
|
||||||
|
}
|
||||||
|
|
||||||
|
func BoxItems(_html *template.Template) *BoxItemActions {
|
||||||
|
html = _html
|
||||||
|
|
||||||
|
return &BoxItemActions{
|
||||||
|
Get: BoxItemsHandler,
|
||||||
|
GetAll: nil,
|
||||||
|
GetByID: nil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BoxItemsHandler(r *http.Request) *web.Response {
|
||||||
|
switch r.Method {
|
||||||
|
|
||||||
|
case http.MethodGet:
|
||||||
|
if r.URL.Query().Has("boxid") {
|
||||||
|
return GetBoxItemsByBoxID(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, count := web.PathLast(r)
|
||||||
|
if count == 1 {
|
||||||
|
return GetAllBoxItems(r)
|
||||||
|
} else {
|
||||||
|
return GetBoxItemByID(r)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAllBoxItems(_ *http.Request) *web.Response {
|
||||||
|
items, err := db.GetAllBoxItems()
|
||||||
|
if err != nil {
|
||||||
|
return web.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
err,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.HTML(
|
||||||
|
http.StatusOK,
|
||||||
|
html,
|
||||||
|
"box-items/box-item-list.html",
|
||||||
|
items,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetBoxItemsByBoxID(r *http.Request) *web.Response {
|
||||||
|
boxID := r.URL.Query().Get("boxid")
|
||||||
|
|
||||||
|
if id, err := strconv.ParseInt(boxID, 10, 64); err != nil {
|
||||||
|
return web.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
err,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
items, err := db.GetBoxItemsByBoxID(int(id))
|
||||||
|
if err != nil {
|
||||||
|
return web.Error(
|
||||||
|
http.StatusNotFound,
|
||||||
|
err,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.HTML(
|
||||||
|
http.StatusOK,
|
||||||
|
html,
|
||||||
|
"box-items/box-item-list.html",
|
||||||
|
items,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetBoxItemByID(_ *http.Request) *web.Response {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -8,43 +8,36 @@ import (
|
|||||||
"github.com/jritsema/gotoolbox/web"
|
"github.com/jritsema/gotoolbox/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Boxes(_html *template.Template) *Router {
|
type BoxActions struct {
|
||||||
|
GetAll func(r *http.Request) *web.Response
|
||||||
|
GetByID func(r *http.Request) *web.Response
|
||||||
|
Post func(r *http.Request) *web.Response
|
||||||
|
Put func(r *http.Request) *web.Response
|
||||||
|
Delete func(r *http.Request) *web.Response
|
||||||
|
}
|
||||||
|
|
||||||
|
func Boxes(_html *template.Template) *BoxActions {
|
||||||
html = _html
|
html = _html
|
||||||
|
|
||||||
return NewRouter(
|
return &BoxActions{
|
||||||
"boxes",
|
|
||||||
RouterActions{
|
|
||||||
GetAll: GetAllBoxes,
|
GetAll: GetAllBoxes,
|
||||||
GetByID: nil,
|
GetByID: nil,
|
||||||
Post: nil,
|
Post: nil,
|
||||||
Put: nil,
|
Put: nil,
|
||||||
Delete: nil,
|
Delete: nil,
|
||||||
},
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllBoxes(_ *http.Request) *web.Response {
|
func GetAllBoxes(_ *http.Request) *web.Response {
|
||||||
result, err := db.GetAll("boxes")
|
result, err := db.GetAllBoxes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return web.Error(http.StatusBadRequest, err, nil)
|
return web.Error(http.StatusBadRequest, err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
boxes := []db.Box{}
|
|
||||||
|
|
||||||
for result.Next() {
|
|
||||||
box := db.Box{}
|
|
||||||
err = db.ParseBox(&box, result.Scan)
|
|
||||||
if err != nil {
|
|
||||||
return web.Error(http.StatusInternalServerError, err, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
boxes = append(boxes, box)
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.HTML(
|
return web.HTML(
|
||||||
http.StatusOK,
|
http.StatusOK,
|
||||||
html,
|
html,
|
||||||
"entity-list.html",
|
"boxes/box-list.html",
|
||||||
result,
|
result,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
// "github.com/innocuous-symmetry/moving-mgmt/"
|
// "github.com/innocuous-symmetry/moving-mgmt/"
|
||||||
db "github.com/innocuous-symmetry/moving-mgmt/db"
|
db "github.com/innocuous-symmetry/moving-mgmt/db"
|
||||||
"github.com/jritsema/gotoolbox/web"
|
"github.com/jritsema/gotoolbox/web"
|
||||||
@@ -14,32 +12,15 @@ var html *template.Template
|
|||||||
|
|
||||||
func HomePage(r *http.Request) *web.Response {
|
func HomePage(r *http.Request) *web.Response {
|
||||||
result, err := db.GetAllItems()
|
result, err := db.GetAllItems()
|
||||||
|
|
||||||
fmt.Println(result)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return web.Error(http.StatusNotFound, err, nil)
|
panic(err)
|
||||||
}
|
|
||||||
|
|
||||||
items := []db.Item{}
|
|
||||||
for result.Next() {
|
|
||||||
item := db.Item{}
|
|
||||||
err = db.ParseItem(&item, result.Scan)
|
|
||||||
|
|
||||||
fmt.Println("name", item.Name)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return web.Error(http.StatusInternalServerError, err, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
items = append(items, item)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return web.HTML(
|
return web.HTML(
|
||||||
http.StatusOK,
|
http.StatusOK,
|
||||||
html,
|
html,
|
||||||
"index.html",
|
"index.html",
|
||||||
items,
|
result,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
244
routes/items.go
244
routes/items.go
@@ -1,113 +1,200 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
db "github.com/innocuous-symmetry/moving-mgmt/db"
|
db "github.com/innocuous-symmetry/moving-mgmt/db"
|
||||||
"github.com/innocuous-symmetry/moving-mgmt/util"
|
|
||||||
"github.com/jritsema/gotoolbox/web"
|
"github.com/jritsema/gotoolbox/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Items(_html *template.Template) *Router {
|
type ItemActions struct {
|
||||||
|
Get func(r *http.Request) *web.Response
|
||||||
|
GetAll func(r *http.Request) *web.Response
|
||||||
|
Edit func(r *http.Request) *web.Response
|
||||||
|
Delete func(r *http.Request) *web.Response
|
||||||
|
Save func(r *http.Request) *web.Response
|
||||||
|
Post func(r *http.Request) *web.Response
|
||||||
|
Add func(r *http.Request) *web.Response
|
||||||
|
}
|
||||||
|
|
||||||
|
func Items(_html *template.Template) *ItemActions {
|
||||||
html = _html
|
html = _html
|
||||||
|
|
||||||
return NewRouter(
|
return &ItemActions{
|
||||||
"items",
|
Get: Get,
|
||||||
RouterActions{
|
|
||||||
GetAll: GetAllItems,
|
GetAll: GetAllItems,
|
||||||
GetByID: GetItemByID,
|
Edit: EditItem,
|
||||||
Post: nil,
|
Delete: Delete,
|
||||||
Put: nil,
|
Save: Put,
|
||||||
Delete: nil,
|
Post: Post,
|
||||||
},
|
Add: Add,
|
||||||
)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Get(r *http.Request) *web.Response {
|
||||||
|
_, count := web.PathLast(r)
|
||||||
|
|
||||||
|
if count == 1 {
|
||||||
|
return GetAllItems(r)
|
||||||
|
} else {
|
||||||
|
return GetItemByID(r)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllItems(_ *http.Request) *web.Response {
|
func GetAllItems(_ *http.Request) *web.Response {
|
||||||
result, err := db.GetAll("items")
|
result, err := db.GetAllItems()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return web.Error(http.StatusNotFound, err, nil)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
items := []db.Item{}
|
|
||||||
|
|
||||||
for result.Next() {
|
|
||||||
item := db.Item{}
|
|
||||||
err = db.ParseItem(&item, result.Scan)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err.Error())
|
|
||||||
return web.Error(http.StatusInternalServerError, err, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
items = append(items, item)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("items", items)
|
|
||||||
|
|
||||||
return web.HTML(
|
return web.HTML(
|
||||||
http.StatusOK,
|
http.StatusOK,
|
||||||
html,
|
html,
|
||||||
"entity-list.html",
|
"items/entity-list.html",
|
||||||
|
result,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func EditItem(r *http.Request) *web.Response {
|
||||||
|
idFromPath, _ := web.PathLast(r)
|
||||||
|
|
||||||
|
id, err := strconv.ParseInt(idFromPath, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return web.Error(http.StatusBadRequest, err, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := db.GetItemByID(int(id))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return web.Error(http.StatusInternalServerError, err, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.HTML(
|
||||||
|
http.StatusOK,
|
||||||
|
html,
|
||||||
|
"items/entity-edit.html",
|
||||||
result,
|
result,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetItemByID(r *http.Request) *web.Response {
|
func GetItemByID(r *http.Request) *web.Response {
|
||||||
id, err := util.GetIDFromPath(r)
|
idFromPath, _ := web.PathLast(r)
|
||||||
|
|
||||||
|
id, err := strconv.ParseInt(idFromPath, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return web.Error(http.StatusBadRequest, err, nil)
|
return web.Error(http.StatusBadRequest, err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
editMode, err := strconv.ParseBool(r.URL.Query().Get("edit"))
|
result, err := db.GetItemByID(int(id))
|
||||||
if err != nil {
|
|
||||||
return web.Error(http.StatusBadRequest, err, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := db.GetByID("items", id)
|
|
||||||
|
|
||||||
item := db.Item{}
|
|
||||||
err = db.ParseItem(&item, res.Scan)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return web.Error(http.StatusInternalServerError, err, nil)
|
return web.Error(http.StatusInternalServerError, err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
var tmpl string
|
|
||||||
|
|
||||||
if editMode {
|
|
||||||
tmpl = "entity-edit.html"
|
|
||||||
} else {
|
|
||||||
tmpl = "entity-row.html"
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.HTML(
|
return web.HTML(
|
||||||
http.StatusOK,
|
http.StatusOK,
|
||||||
html,
|
html,
|
||||||
tmpl,
|
"items/entity-row.html",
|
||||||
|
result,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Put(r *http.Request) *web.Response {
|
||||||
|
id, _ := web.PathLast(r)
|
||||||
|
|
||||||
|
if err := r.ParseForm(); err != nil {
|
||||||
|
return web.Error(http.StatusBadRequest, err, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Form.Get("category") == "" {
|
||||||
|
panic(r.Form.Get(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Form.Get("stage") == "" {
|
||||||
|
panic(r.Form.Get(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
name := r.Form.Get("name")
|
||||||
|
stage := r.Form.Get("stage")
|
||||||
|
category := r.Form.Get("category")
|
||||||
|
description := r.Form.Get("description")
|
||||||
|
notes := r.Form.Get("notes")
|
||||||
|
// id := r.Form.Get("id")
|
||||||
|
|
||||||
|
item := db.Item{
|
||||||
|
ID: func() int {
|
||||||
|
idInt, err := strconv.ParseInt(id, 10, 64)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
return int(idInt)
|
||||||
|
}(),
|
||||||
|
|
||||||
|
Name: name,
|
||||||
|
Description: &description,
|
||||||
|
Notes: ¬es,
|
||||||
|
|
||||||
|
Stage: func() db.PackingStage {
|
||||||
|
stageInt, _ := strconv.Atoi(stage)
|
||||||
|
return db.PackingStage(stageInt)
|
||||||
|
}(),
|
||||||
|
|
||||||
|
Category: func() db.Category {
|
||||||
|
categoryInt, _ := strconv.Atoi(category)
|
||||||
|
return db.Category(categoryInt)
|
||||||
|
}(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := db.PutItem(item); err != nil {
|
||||||
|
return web.Error(http.StatusInternalServerError, err, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.HTML(
|
||||||
|
http.StatusOK,
|
||||||
|
html,
|
||||||
|
"items/entity-row.html",
|
||||||
item,
|
item,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PutItem(r *http.Request) *web.Response {
|
func Post(r *http.Request) *web.Response {
|
||||||
body := r.Body
|
err := r.ParseForm()
|
||||||
defer body.Close()
|
|
||||||
|
|
||||||
bodyBytes := make([]byte, r.ContentLength)
|
|
||||||
_, err := body.Read(bodyBytes)
|
|
||||||
if err != nil {
|
|
||||||
return web.Error(http.StatusInternalServerError, err, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
item, err := db.ParseEntityFromBytes(bodyBytes)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return web.Error(http.StatusBadRequest, err, nil)
|
return web.Error(http.StatusBadRequest, err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := db.Put("items", item)
|
name := r.Form.Get("name")
|
||||||
|
stage := r.Form.Get("stage")
|
||||||
|
category := r.Form.Get("category")
|
||||||
|
description := r.Form.Get("description")
|
||||||
|
notes := r.Form.Get("notes")
|
||||||
|
|
||||||
|
item := db.Item{
|
||||||
|
Name: name,
|
||||||
|
Description: &description,
|
||||||
|
Notes: ¬es,
|
||||||
|
|
||||||
|
Stage: func() db.PackingStage {
|
||||||
|
stageInt, _ := strconv.Atoi(stage)
|
||||||
|
return db.PackingStage(stageInt)
|
||||||
|
}(),
|
||||||
|
|
||||||
|
Category: func() db.Category {
|
||||||
|
categoryInt, _ := strconv.Atoi(category)
|
||||||
|
return db.Category(categoryInt)
|
||||||
|
}(),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = db.PostItem(item)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return web.Error(http.StatusInternalServerError, err, nil)
|
return web.Error(http.StatusInternalServerError, err, nil)
|
||||||
}
|
}
|
||||||
@@ -115,8 +202,41 @@ func PutItem(r *http.Request) *web.Response {
|
|||||||
return web.HTML(
|
return web.HTML(
|
||||||
http.StatusOK,
|
http.StatusOK,
|
||||||
html,
|
html,
|
||||||
"entity-row.html",
|
"items/entity-add-success.html",
|
||||||
result,
|
item,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Add(r *http.Request) *web.Response {
|
||||||
|
return web.HTML(
|
||||||
|
http.StatusOK,
|
||||||
|
html,
|
||||||
|
"items/items/entity-add.html",
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Delete(r *http.Request) *web.Response {
|
||||||
|
idFromPath, _ := web.PathLast(r)
|
||||||
|
id, err := strconv.ParseInt(idFromPath, 10, 64)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return web.Error(http.StatusBadRequest, err, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = db.DeleteItem(int(id))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return web.Error(http.StatusInternalServerError, err, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.HTML(
|
||||||
|
http.StatusOK,
|
||||||
|
html,
|
||||||
|
"items/entity-row.html",
|
||||||
|
nil,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
0
scripts/index.js
Normal file
0
scripts/index.js
Normal file
23
templates/box-items/box-item-list.html
Normal file
23
templates/box-items/box-item-list.html
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<tr class="box-item-list">
|
||||||
|
<td>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="px-6 py-4"></th>
|
||||||
|
<th scope="col" class="px-6 py-4">#</th>
|
||||||
|
<th scope="col" class="px-6 py-4">Name</th>
|
||||||
|
<th scope="col" class="px-6 py-4">Stage</th>
|
||||||
|
<th scope="col" class="px-6 py-4">Category</th>
|
||||||
|
<th scope="col" class="px-6 py-4">Description</th>
|
||||||
|
<th scope="col" class="px-6 py-4">Notes</th>
|
||||||
|
<th scope="col" class="px-6 py-4"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="table-body">
|
||||||
|
{{range .}}
|
||||||
|
{{ template "box-items/box-item-row.html" . }}
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
10
templates/box-items/box-item-row.html
Normal file
10
templates/box-items/box-item-row.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<tr class="box-item-row border-b dark:border-neutral-500 hover:bg-slate-300 hover:bg-opacity-20">
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">{{ .ID }}</td>
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">{{ .Name }}</td>
|
||||||
|
|
||||||
|
{{ template "components/parsed-packing-stage.html" .Stage }}
|
||||||
|
{{ template "components/parsed-category.html" .Category }}
|
||||||
|
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">{{ .Description }}</td>
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">{{ .Notes }}</td>
|
||||||
|
</tr>
|
||||||
@@ -1,35 +1,25 @@
|
|||||||
<div id="box-list">
|
<div id="boxes/box-list">
|
||||||
<div id="processing" class="htmx-indicator">Processing...</div>
|
<div id="processing" class="htmx-indicator">Processing...</div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<div class="overflow-x-auto sm:-mx-6 lg:-mx-8">
|
<div class="overflow-x-auto sm:-mx-6 lg:-mx-8">
|
||||||
<div class="inline-block min-w-full py-2 sm:px-6 lg:px-8">
|
<div class="inline-block min-w-full py-2 sm:px-6 lg:px-8">
|
||||||
<div class="overflow-hidden">
|
<div class="overflow-hidden">
|
||||||
<!-- <div class="flex justify-end">
|
|
||||||
<button
|
|
||||||
hx-get="/company/add"
|
|
||||||
hx-target="#table-body"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
hx-indicator="#processing"
|
|
||||||
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
|
||||||
href=""
|
|
||||||
>
|
|
||||||
Add
|
|
||||||
</button>
|
|
||||||
</div> -->
|
|
||||||
<table class="min-w-full text-left text-sm font-light">
|
<table class="min-w-full text-left text-sm font-light">
|
||||||
<thead class="border-b font-medium dark:border-neutral-500">
|
<thead class="border-b font-medium dark:border-neutral-500">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th scope="col" class="px-6 py-4"></th>
|
||||||
<th scope="col" class="px-6 py-4">#</th>
|
<th scope="col" class="px-6 py-4">#</th>
|
||||||
<th scope="col" class="px-6 py-4">Name</th>
|
<th scope="col" class="px-6 py-4">Name</th>
|
||||||
<th scope="col" class="px-6 py-4">Stage</th>
|
<th scope="col" class="px-6 py-4">Stage</th>
|
||||||
<th scope="col" class="px-6 py-4">Category</th>
|
<th scope="col" class="px-6 py-4">Category</th>
|
||||||
<th scope="col" class="px-6 py-4">Description</th>
|
<th scope="col" class="px-6 py-4">Description</th>
|
||||||
<th scope="col" class="px-6 py-4">Notes</th>
|
<th scope="col" class="px-6 py-4">Notes</th>
|
||||||
|
<th scope="col" class="px-6 py-4"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="table-body">
|
<tbody id="table-body">
|
||||||
{{range .}}
|
{{range .}}
|
||||||
{{ template "entity-row.html". }}
|
{{ template "boxes/box-row.html" . }}
|
||||||
{{end}}
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
40
templates/boxes/box-row.html
Normal file
40
templates/boxes/box-row.html
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<tr id="boxrow-{{.ID}}" class="border-b dark:border-neutral-500 hover:bg-slate-300 hover:bg-opacity-20">
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">
|
||||||
|
<button
|
||||||
|
hx-get="/box-items?boxid={{ .ID }}"
|
||||||
|
hx-target="#boxrow-{{ .ID }}"
|
||||||
|
hx-swap="afterend"
|
||||||
|
class="inline-flex items-center h-8 px-4 m-2 text-sm text-stone-100 transition-colors duration-150 bg-stone-700 rounded-lg focus:shadow-outline hover:bg-stone-800"
|
||||||
|
>
|
||||||
|
>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">{{.ID}}</td>
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">{{.Name}}</td>
|
||||||
|
|
||||||
|
{{ template "components/parsed-packing-stage.html" .ID }}
|
||||||
|
|
||||||
|
{{ template "components/parsed-category.html" .ID }}
|
||||||
|
|
||||||
|
{{ if .Description }}
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">{{.Description}}</td>
|
||||||
|
{{ else }}
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">...</td>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if .Notes }}
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">{{.Notes}}</td>
|
||||||
|
{{ else }}
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">...</td>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">
|
||||||
|
<button
|
||||||
|
hx-get="/items/edit/{{ .ID }}"
|
||||||
|
hx-target="#boxrow-{{ .ID }}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
class="inline-flex items-center h-8 px-4 m-2 text-sm text-yellow-100 transition-colors duration-150 bg-yellow-700 rounded-lg focus:shadow-outline hover:bg-yellow-800"
|
||||||
|
>
|
||||||
|
Edit
|
||||||
|
</button>
|
||||||
|
</tr>
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<div id="companies">
|
|
||||||
<div id="processing" class="htmx-indicator">Processing...</div>
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<div class="overflow-x-auto sm:-mx-6 lg:-mx-8">
|
|
||||||
<div class="inline-block min-w-full py-2 sm:px-6 lg:px-8">
|
|
||||||
<div class="overflow-hidden">
|
|
||||||
<div class="flex justify-end">
|
|
||||||
<button
|
|
||||||
hx-get="/company/add"
|
|
||||||
hx-target="#table-body"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
hx-indicator="#processing"
|
|
||||||
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
|
||||||
href=""
|
|
||||||
>
|
|
||||||
Add
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<table class="min-w-full text-left text-sm font-light">
|
|
||||||
<thead class="border-b font-medium dark:border-neutral-500">
|
|
||||||
<tr>
|
|
||||||
<th scope="col" class="px-6 py-4">#</th>
|
|
||||||
<th scope="col" class="px-6 py-4">Company</th>
|
|
||||||
<th scope="col" class="px-6 py-4">Contact</th>
|
|
||||||
<th scope="col" class="px-6 py-4">Country</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="table-body">
|
|
||||||
{{range .}}
|
|
||||||
{{ template "row.html". }}
|
|
||||||
{{end}}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<tbody id="table-body">
|
|
||||||
{{ template "row-add.html" . }}
|
|
||||||
{{range .}}
|
|
||||||
{{ template "row.html". }}
|
|
||||||
{{end}}
|
|
||||||
</tbody>
|
|
||||||
8
templates/components/add-category.html
Normal file
8
templates/components/add-category.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<select class="data-input-NEW_ITEM_ROW" id="category-selector-NEW_ITEM_ROW" data-include-edit="NEW_ITEM_ROW" name="category">
|
||||||
|
<option value="0">Bedroom</option>
|
||||||
|
<option value="1">Bathroom</option>
|
||||||
|
<option value="2">Kitchen</option>
|
||||||
|
<option value="3">Office</option>
|
||||||
|
<option value="4">Living Room</option>
|
||||||
|
<option value="5">Other</option>
|
||||||
|
</select>
|
||||||
7
templates/components/add-packing-stage.html
Normal file
7
templates/components/add-packing-stage.html
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<select class="data-input-NEW_ITEM_ROW" id="packing-stage-selector-NEW_ITEM_ROW" data-include-edit="NEW_ITEM_ROW" name="stage">
|
||||||
|
<option value="0">Essentials</option>
|
||||||
|
<option value="1">Stage One</option>
|
||||||
|
<option value="2">Stage Two</option>
|
||||||
|
<option value="3">Stage Three</option>
|
||||||
|
<option value="4">Determine Later</option>
|
||||||
|
</select>
|
||||||
8
templates/components/edit-category.html
Normal file
8
templates/components/edit-category.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<select class="data-input-{{.ID}}" id="category-selector-{{.ID}}" data-include-edit="{{.ID}}" value="{{.Category}}" name="category">
|
||||||
|
<option value="0">Bedroom</option>
|
||||||
|
<option value="1">Bathroom</option>
|
||||||
|
<option value="2">Kitchen</option>
|
||||||
|
<option value="3">Office</option>
|
||||||
|
<option value="4">Living Room</option>
|
||||||
|
<option value="5">Other</option>
|
||||||
|
</select>
|
||||||
7
templates/components/edit-packing-stage.html
Normal file
7
templates/components/edit-packing-stage.html
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<select class="data-input-{{.ID}}" id="packing-stage-selector-{{.ID}}" data-include-edit="{{.ID}}" value="{{.Stage}}" name="stage">
|
||||||
|
<option value="0">Essentials</option>
|
||||||
|
<option value="1">Stage One</option>
|
||||||
|
<option value="2">Stage Two</option>
|
||||||
|
<option value="3">Stage Three</option>
|
||||||
|
<option value="4">Determine Later</option>
|
||||||
|
</select>
|
||||||
27
templates/components/parsed-category.html
Normal file
27
templates/components/parsed-category.html
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<td class="whitespace-nowrap px-6 py-4">
|
||||||
|
{{ if eq . 0 }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-purple-100 text-purple-800">
|
||||||
|
Bedroom
|
||||||
|
</span>
|
||||||
|
{{ else if eq . 1 }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-cyan-100 text-cyan-800">
|
||||||
|
Bathroom
|
||||||
|
</span>
|
||||||
|
{{ else if eq . 2 }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-orange-100 text-orange-800">
|
||||||
|
Kitchen
|
||||||
|
</span>
|
||||||
|
{{ else if eq . 3 }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-rose-100 text-rose-800">
|
||||||
|
Office
|
||||||
|
</span>
|
||||||
|
{{ else if eq . 4 }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-indigo-100 text-indigo-800">
|
||||||
|
Living Room
|
||||||
|
</span>
|
||||||
|
{{ else }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">
|
||||||
|
Other
|
||||||
|
</span>
|
||||||
|
{{ end }}
|
||||||
|
</td>
|
||||||
23
templates/components/parsed-packing-stage.html
Normal file
23
templates/components/parsed-packing-stage.html
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<td class="whitespace-nowrap px-6 py-4">
|
||||||
|
{{ if eq . 0 }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
|
||||||
|
Essentials
|
||||||
|
</span>
|
||||||
|
{{ else if eq . 1 }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-cyan-100 text-cyan-800">
|
||||||
|
Stage One
|
||||||
|
</span>
|
||||||
|
{{ else if eq . 2 }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-purple-100 text-purple-800">
|
||||||
|
Stage Two
|
||||||
|
</span>
|
||||||
|
{{ else if eq . 3 }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-stone-100 text-stone-800">
|
||||||
|
Stage Three
|
||||||
|
</span>
|
||||||
|
{{ else }}
|
||||||
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-amber-100 text-amber-800">
|
||||||
|
Determine Later
|
||||||
|
</span>
|
||||||
|
{{ end }}
|
||||||
|
</td>
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<tr id="datarow-{{.ID}}" class="border-b dark:border-neutral-500">
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.ID}}</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.Name}}</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.Stage}}</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.Category}}</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.Description}}</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.Notes}}</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">
|
|
||||||
<button
|
|
||||||
hx-get="/items/{{.ID}}"
|
|
||||||
hx-params="edit=true"
|
|
||||||
hx-target="#datarow-{{.ID}}"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
|
||||||
>
|
|
||||||
Edit
|
|
||||||
</button>
|
|
||||||
</tr>
|
|
||||||
@@ -4,13 +4,13 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||||
<script src="https://unpkg.com/htmx.org@1.9.2"></script>
|
|
||||||
<link href="/css/output.css" rel="stylesheet" />
|
|
||||||
<title>Mikayla's Move Manager</title>
|
<title>Mikayla's Move Manager</title>
|
||||||
|
<script src="https://unpkg.com/htmx.org@1.9.2"></script>
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<div class="md:container md:mx-auto">
|
<div class="md:container md:mx-auto w-full max-w-screen">
|
||||||
<h1 class="text-3xl">Mikayla's Move Manager</h1>
|
<h1 class="text-3xl">Mikayla's Move Manager</h1>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
hx-get="/items"
|
hx-get="/items"
|
||||||
hx-target="#home-page-container"
|
hx-target="#home-page-container"
|
||||||
hx-swap="innerHTML"
|
hx-swap="innerHTML"
|
||||||
|
onclick="handleLabelUpdate"
|
||||||
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
||||||
>
|
>
|
||||||
Items
|
Items
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
hx-get="/boxes"
|
hx-get="/boxes"
|
||||||
hx-target="#home-page-container"
|
hx-target="#home-page-container"
|
||||||
hx-swap="innerHTML"
|
hx-swap="innerHTML"
|
||||||
|
onclick="handleLabelUpdate"
|
||||||
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
||||||
>
|
>
|
||||||
Boxes
|
Boxes
|
||||||
@@ -34,13 +36,18 @@
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
<span id="page-label" class="text-xl">Items</span>
|
||||||
<span class="text-xl">Items</span>
|
|
||||||
|
|
||||||
<div id="home-page-container">
|
<div id="home-page-container">
|
||||||
{{ template "entity-list.html" . }}
|
{{ template "items/entity-list.html" . }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function handleLabelUpdate() {
|
||||||
|
const prev = document.getElementById('page-label').innerText;
|
||||||
|
document.getElementById('page-label').innerText = prev === 'Items' ? 'Boxes' : 'Items';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
2
templates/items/entity-add-success.html
Normal file
2
templates/items/entity-add-success.html
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
{{ template "items/entity-row.html" . }}
|
||||||
|
{{ template "items/entity-add.html" }}
|
||||||
52
templates/items/entity-add.html
Normal file
52
templates/items/entity-add.html
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<tr id="datarow-NEW_ITEM_ROW" class="datarow border-b dark:border-neutral-500">
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">
|
||||||
|
<!-- <input hidden disabled type="text" name="id" value="NEW_ITEM_ROW" data-include-edit="NEW_ITEM_ROW" />
|
||||||
|
<span>NEW_ITEM_ROW</span> -->
|
||||||
|
</td>
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">
|
||||||
|
<input
|
||||||
|
placeholder="Item name"
|
||||||
|
type="text"
|
||||||
|
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||||
|
data-include-edit="NEW_ITEM_ROW"
|
||||||
|
name="name"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">
|
||||||
|
{{ template "components/add-packing-stage.html" }}
|
||||||
|
</td>
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">
|
||||||
|
{{ template "components/add-category.html" }}
|
||||||
|
</td>
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Short description"
|
||||||
|
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||||
|
data-include-edit="NEW_ITEM_ROW"
|
||||||
|
name="description"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td class="whitespace-nowrap px-6 py-4">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Notes"
|
||||||
|
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||||
|
data-include-edit="NEW_ITEM_ROW"
|
||||||
|
name="notes"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<td class="whitespace-nowrap px-1 py-1">
|
||||||
|
<a
|
||||||
|
id="add-new-item-button-NEW_ITEM_ROW"
|
||||||
|
hx-post="/items/add"
|
||||||
|
hx-target="#datarow-NEW_ITEM_ROW"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-indicator="#processing"
|
||||||
|
hx-include="[data-include-edit='NEW_ITEM_ROW']"
|
||||||
|
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
||||||
|
href=""
|
||||||
|
>Add</a
|
||||||
|
>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
80
templates/items/entity-edit.html
Normal file
80
templates/items/entity-edit.html
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<tr id="datarow-{{.ID}}" class="datarow w-full border-b dark:border-neutral-500">
|
||||||
|
<td id="datarow-{{.ID}}-id" class="hidden md:flex whitespace-nowrap px-6 py-4 w-1/12">
|
||||||
|
<input class="data-input-{{.ID}}" hidden disabled type="text" name="id" value="{{.ID}}" data-include-edit="{{.ID}}" />
|
||||||
|
<span>{{.ID}}</span>
|
||||||
|
</td>
|
||||||
|
<td id="datarow-{{.ID}}-name" class="whitespace-nowrap px-6 py-4 w-1/4 md:w-1/6">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="data-input-{{.ID}} shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||||
|
data-include-edit="{{.ID}}"
|
||||||
|
name="name"
|
||||||
|
value="{{.Name}}"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td id="datarow-{{.ID}}-stage" class="whitespace-nowrap px-6 py-4 w-1/4 md:w-1/6">
|
||||||
|
{{ template "components/edit-packing-stage.html" . }}
|
||||||
|
</td>
|
||||||
|
<td id="datarow-{{.ID}}-category" class="whitespace-nowrap px-6 py-4 w-1/4 md:w-1/6">
|
||||||
|
{{ template "components/edit-category.html" . }}
|
||||||
|
</td>
|
||||||
|
<td id="datarow-{{.ID}}-description" class="hidden md:flex px-6 py-4 w-1/6">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="data-input-{{.ID}} shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||||
|
data-include-edit="{{.ID}}"
|
||||||
|
name="description"
|
||||||
|
value="{{.Description}}"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td id="datarow-{{.ID}}-notes" class="hidden md:flex px-6 py-4 w-1/6">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="data-input-{{.ID}} shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||||
|
data-include-edit="{{.ID}}"
|
||||||
|
name="notes"
|
||||||
|
value="{{.Notes}}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<td id="datarow-{{.ID}}-actions" class="whitespace-nowrap flex items-end px-1 py-1 w-1/4 md:w-1/12">
|
||||||
|
<a
|
||||||
|
id="datarow-{{.ID}}-save"
|
||||||
|
hx-put="/items/save/{{.ID}}"
|
||||||
|
hx-target="#datarow-{{.ID}}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-indicator="#processing"
|
||||||
|
hx-include=".data-input-{{.ID}}"
|
||||||
|
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
||||||
|
href=""
|
||||||
|
>Save</a
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
hx-get="/items/{{.ID}}"
|
||||||
|
hx-target="#datarow-{{.ID}}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-indicator="#processing"
|
||||||
|
class="inline-flex items-center h-8 px-4 m-2 text-sm text-red-100 transition-colors duration-150 bg-red-700 rounded-lg focus:shadow-outline hover:bg-red-800"
|
||||||
|
href=""
|
||||||
|
>Cancel</a
|
||||||
|
>
|
||||||
|
</td>
|
||||||
|
<script>
|
||||||
|
window.addEventListener("keydown", (e) => {
|
||||||
|
/** @typedef KeyboardEvent */
|
||||||
|
const target = e.target;
|
||||||
|
|
||||||
|
if (e.target.key == "Enter") {
|
||||||
|
const a = document.getElementById("datarow-{{.ID}}-save");
|
||||||
|
void a.click();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
document.getElementById("category-selector-{{.ID}}").onchange = (e) => {
|
||||||
|
console.log(e.target.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("packing-stage-selector-{{.ID}}").onchange = (e) => {
|
||||||
|
console.log(e.target.value);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</tr>
|
||||||
@@ -4,18 +4,6 @@
|
|||||||
<div class="overflow-x-auto sm:-mx-6 lg:-mx-8">
|
<div class="overflow-x-auto sm:-mx-6 lg:-mx-8">
|
||||||
<div class="inline-block min-w-full py-2 sm:px-6 lg:px-8">
|
<div class="inline-block min-w-full py-2 sm:px-6 lg:px-8">
|
||||||
<div class="overflow-hidden">
|
<div class="overflow-hidden">
|
||||||
<!-- <div class="flex justify-end">
|
|
||||||
<button
|
|
||||||
hx-get="/company/add"
|
|
||||||
hx-target="#table-body"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
hx-indicator="#processing"
|
|
||||||
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
|
||||||
href=""
|
|
||||||
>
|
|
||||||
Add
|
|
||||||
</button>
|
|
||||||
</div> -->
|
|
||||||
<table class="min-w-full text-left text-sm font-light">
|
<table class="min-w-full text-left text-sm font-light">
|
||||||
<thead class="border-b font-medium dark:border-neutral-500">
|
<thead class="border-b font-medium dark:border-neutral-500">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -25,12 +13,15 @@
|
|||||||
<th scope="col" class="px-6 py-4">Category</th>
|
<th scope="col" class="px-6 py-4">Category</th>
|
||||||
<th scope="col" class="px-6 py-4">Description</th>
|
<th scope="col" class="px-6 py-4">Description</th>
|
||||||
<th scope="col" class="px-6 py-4">Notes</th>
|
<th scope="col" class="px-6 py-4">Notes</th>
|
||||||
|
<th scope="col" class="px-6 py-4"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="table-body">
|
<tbody id="table-body">
|
||||||
{{range .}}
|
{{range .}}
|
||||||
{{ template "entity-row.html". }}
|
{{ template "items/entity-row.html" . }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
{{ template "items/entity-add.html" . }}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
46
templates/items/entity-row.html
Normal file
46
templates/items/entity-row.html
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<tr id="datarow-{{.ID}}" class="border-b dark:border-neutral-500 hover:bg-slate-300 hover:bg-opacity-20">
|
||||||
|
<td class="whitespace-nowrap items-center justify-center w-1/12">{{.ID}}</td>
|
||||||
|
|
||||||
|
<td class="whitespace-nowrap px-6 py-4 w-1/6">{{.Name}}</td>
|
||||||
|
|
||||||
|
<td class="whitespace-nowrap px-6 py-4 w-1/6">
|
||||||
|
{{ template "components/parsed-packing-stage.html" .Stage }}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="whitespace-nowrap px-6 py-4 w-1/6">
|
||||||
|
{{ template "components/parsed-category.html" .Category }}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
{{ if .Description }}
|
||||||
|
<td class="w-1/6 px-6 py-4 ">{{.Description}}</td>
|
||||||
|
{{ else }}
|
||||||
|
<td class="w-1/6 px-6 py-4 ">...</td>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if .Notes }}
|
||||||
|
<td class="w-1/6 px-6 py-4 ">{{.Notes}}</td>
|
||||||
|
{{ else }}
|
||||||
|
<td class="w-1/6 px-6 py-4 ">...</td>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<td class="whitespace-nowrap px-6 py-4 w-1/12">
|
||||||
|
<button
|
||||||
|
hx-get="/items/edit/{{ .ID }}"
|
||||||
|
hx-target="#datarow-{{ .ID }}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
class="inline-flex items-center h-8 px-4 m-2 text-sm text-yellow-100 transition-colors duration-150 bg-yellow-700 rounded-lg focus:shadow-outline hover:bg-yellow-800"
|
||||||
|
>
|
||||||
|
Edit
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
hx-delete="/items/delete/{{ .ID }}"
|
||||||
|
hx-confirm="Are you sure?"
|
||||||
|
hx-target="#datarow-{{ .ID }}"
|
||||||
|
hx-swap="delete"
|
||||||
|
class="inline-flex items-center h-8 px-4 m-2 text-sm text-red-100 transition-colors duration-150 bg-red-700 rounded-lg focus:shadow-outline hover:bg-red-800"
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
<tr id="datarow-add" class="border-b dark:border-neutral-500">
|
|
||||||
<td class="whitespace-nowrap px-6 py-4"></td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
||||||
data-include-add=""
|
|
||||||
name="company"
|
|
||||||
value=""
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
||||||
data-include-add=""
|
|
||||||
name="contact"
|
|
||||||
value=""
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
||||||
data-include-add=""
|
|
||||||
name="country"
|
|
||||||
value=""
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-1 py-1">
|
|
||||||
<a
|
|
||||||
hx-post="/company/"
|
|
||||||
hx-target="#companies"
|
|
||||||
hx-indicator="#processing"
|
|
||||||
hx-include="input[data-include-add]"
|
|
||||||
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
|
||||||
href=""
|
|
||||||
>Save</a
|
|
||||||
>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-1 py-1">
|
|
||||||
<a
|
|
||||||
hx-get="/company/"
|
|
||||||
hx-target="#companies"
|
|
||||||
hx-indicator="#processing"
|
|
||||||
class="inline-flex items-center h-8 px-4 m-2 text-sm text-red-100 transition-colors duration-150 bg-red-700 rounded-lg focus:shadow-outline hover:bg-red-800"
|
|
||||||
href=""
|
|
||||||
>Cancel</a
|
|
||||||
>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
<tr id="datarow-{{.ID}}" class="border-b dark:border-neutral-500">
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.ID}}</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
||||||
data-include-edit="{{.ID}}"
|
|
||||||
name="Name"
|
|
||||||
value="{{.Name}}"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
||||||
data-include-edit="{{.ID}}"
|
|
||||||
name="stage"
|
|
||||||
value="{{.Stage}}"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
||||||
data-include-edit="{{.ID}}"
|
|
||||||
name="Category"
|
|
||||||
value="{{.Category}}"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
||||||
data-include-edit="{{.ID}}"
|
|
||||||
name="Description"
|
|
||||||
value="{{.Description}}"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
|
||||||
data-include-edit="{{.ID}}"
|
|
||||||
name="Notes"
|
|
||||||
value="{{.Notes}}"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-1 py-1">
|
|
||||||
<a
|
|
||||||
hx-put="/items/{{.ID}}"
|
|
||||||
hx-target="#datarow-{{.ID}}"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
hx-indicator="#processing"
|
|
||||||
hx-include="input[data-include-edit='{{.ID}}']"
|
|
||||||
class="inline-flex items-center h-8 px-4 m-2 text-sm text-blue-100 transition-colors duration-150 bg-blue-700 rounded-lg focus:shadow-outline hover:bg-blue-800"
|
|
||||||
href=""
|
|
||||||
>Save</a
|
|
||||||
>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-1 py-1">
|
|
||||||
<a
|
|
||||||
hx-get="/items/{{.ID}}"
|
|
||||||
hx-params="edit=false"
|
|
||||||
hx-target="#datarow-{{.ID}}"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
hx-indicator="#processing"
|
|
||||||
class="inline-flex items-center h-8 px-4 m-2 text-sm text-red-100 transition-colors duration-150 bg-red-700 rounded-lg focus:shadow-outline hover:bg-red-800"
|
|
||||||
href=""
|
|
||||||
>Cancel</a
|
|
||||||
>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<tr id="datarow-{{.ID}}" class="border-b dark:border-neutral-500">
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.ID}}</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.Company}}</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.Contact}}</td>
|
|
||||||
<td class="whitespace-nowrap px-6 py-4">{{.Country}}</td>
|
|
||||||
<td class="whitespace-nowrap px-1 py-1">
|
|
||||||
<a
|
|
||||||
hx-get="/company/edit/{{.ID}}"
|
|
||||||
hx-target="#datarow-{{.ID}}"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
hx-indicator="#processing"
|
|
||||||
class="hover:underline text-blue-700"
|
|
||||||
href=""
|
|
||||||
>
|
|
||||||
Edit
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-1 py-1">
|
|
||||||
<a
|
|
||||||
hx-delete="/company/{{.ID}}"
|
|
||||||
hx-target="#companies"
|
|
||||||
hx-confirm="Are you sure you want to delete {{.Company}}?"
|
|
||||||
hx-indicator="#processing"
|
|
||||||
class="hover:underline text-blue-700"
|
|
||||||
href=""
|
|
||||||
>Delete</a
|
|
||||||
>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
Reference in New Issue
Block a user