diff --git a/modules/common/src/main/scala/docspell/common/Ident.scala b/modules/common/src/main/scala/docspell/common/Ident.scala index 95e58bc6..ded29dc8 100644 --- a/modules/common/src/main/scala/docspell/common/Ident.scala +++ b/modules/common/src/main/scala/docspell/common/Ident.scala @@ -4,9 +4,9 @@ import java.security.SecureRandom import java.util.UUID import cats.Eq +import cats.Order import cats.effect.Sync import cats.implicits._ -import cats.Order import io.circe.{Decoder, Encoder} import scodec.bits.ByteVector diff --git a/modules/restapi/src/main/resources/docspell-openapi.yml b/modules/restapi/src/main/resources/docspell-openapi.yml index 9ac23cd8..01ecdfb1 100644 --- a/modules/restapi/src/main/resources/docspell-openapi.yml +++ b/modules/restapi/src/main/resources/docspell-openapi.yml @@ -4980,6 +4980,8 @@ components: description: DateTime type: integer format: date-time + notes: + type: string ReferenceList: description: Listing of entities with their id and a name. diff --git a/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala b/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala index ddd36923..00c5957b 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala @@ -617,15 +617,17 @@ trait Conversions { // equipment def mkEquipment(re: REquipment): Equipment = - Equipment(re.eid, re.name, re.created) + Equipment(re.eid, re.name, re.created, re.notes) def newEquipment[F[_]: Sync](e: Equipment, cid: Ident): F[REquipment] = timeId.map({ case (id, now) => - REquipment(id, cid, e.name, now, now) + REquipment(id, cid, e.name, now, now, e.notes) }) def changeEquipment[F[_]: Sync](e: Equipment, cid: Ident): F[REquipment] = - Timestamp.current[F].map(now => REquipment(e.id, cid, e.name, e.created, now)) + Timestamp + .current[F] + .map(now => REquipment(e.id, cid, e.name, e.created, now, e.notes)) // idref diff --git a/modules/store/src/main/resources/db/migration/h2/V1.20.1__equipment_description.sql b/modules/store/src/main/resources/db/migration/h2/V1.20.1__equipment_description.sql new file mode 100644 index 00000000..0c18a644 --- /dev/null +++ b/modules/store/src/main/resources/db/migration/h2/V1.20.1__equipment_description.sql @@ -0,0 +1,2 @@ +ALTER TABLE "equipment" +ADD COLUMN "notes" text; diff --git a/modules/store/src/main/resources/db/migration/mariadb/V1.20.1__equipment_description.sql b/modules/store/src/main/resources/db/migration/mariadb/V1.20.1__equipment_description.sql new file mode 100644 index 00000000..57d43464 --- /dev/null +++ b/modules/store/src/main/resources/db/migration/mariadb/V1.20.1__equipment_description.sql @@ -0,0 +1,2 @@ +ALTER TABLE `equipment` +ADD COLUMN `notes` mediumtext; diff --git a/modules/store/src/main/resources/db/migration/postgresql/V1.20.1__equipment_description.sql b/modules/store/src/main/resources/db/migration/postgresql/V1.20.1__equipment_description.sql new file mode 100644 index 00000000..0c18a644 --- /dev/null +++ b/modules/store/src/main/resources/db/migration/postgresql/V1.20.1__equipment_description.sql @@ -0,0 +1,2 @@ +ALTER TABLE "equipment" +ADD COLUMN "notes" text; diff --git a/modules/store/src/main/scala/docspell/store/records/REquipment.scala b/modules/store/src/main/scala/docspell/store/records/REquipment.scala index d1cfa83a..5befc011 100644 --- a/modules/store/src/main/scala/docspell/store/records/REquipment.scala +++ b/modules/store/src/main/scala/docspell/store/records/REquipment.scala @@ -14,7 +14,8 @@ case class REquipment( cid: Ident, name: String, created: Timestamp, - updated: Timestamp + updated: Timestamp, + notes: Option[String] ) {} object REquipment { @@ -26,7 +27,8 @@ object REquipment { val name = Column[String]("name", this) val created = Column[Timestamp]("created", this) val updated = Column[Timestamp]("updated", this) - val all = NonEmptyList.of[Column[_]](eid, cid, name, created, updated) + val notes = Column[String]("notes", this) + val all = NonEmptyList.of[Column[_]](eid, cid, name, created, updated, notes) } val T = Table(None) @@ -39,7 +41,7 @@ object REquipment { .insert( t, t.all, - fr"${v.eid},${v.cid},${v.name},${v.created},${v.updated}" + fr"${v.eid},${v.cid},${v.name},${v.created},${v.updated},${v.notes}" ) } @@ -54,7 +56,8 @@ object REquipment { DML.set( t.cid.setTo(v.cid), t.name.setTo(v.name), - t.updated.setTo(now) + t.updated.setTo(now), + t.notes.setTo(v.notes) ) ) } yield n diff --git a/modules/webapp/src/main/elm/Comp/EquipmentForm.elm b/modules/webapp/src/main/elm/Comp/EquipmentForm.elm index 28ffe0f4..3e0ab5eb 100644 --- a/modules/webapp/src/main/elm/Comp/EquipmentForm.elm +++ b/modules/webapp/src/main/elm/Comp/EquipmentForm.elm @@ -16,11 +16,13 @@ import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (onInput) import Styles as S +import Util.Maybe type alias Model = { equipment : Equipment , name : String + , notes : Maybe String } @@ -28,6 +30,7 @@ emptyModel : Model emptyModel = { equipment = Api.Model.Equipment.empty , name = "" + , notes = Nothing } @@ -38,23 +41,37 @@ isValid model = getEquipment : Model -> Equipment getEquipment model = - Equipment model.equipment.id model.name model.equipment.created + { id = model.equipment.id + , name = model.name + , created = model.equipment.created + , notes = model.notes + } type Msg = SetName String | SetEquipment Equipment + | SetNotes String update : Flags -> Msg -> Model -> ( Model, Cmd Msg ) update _ msg model = case msg of SetEquipment t -> - ( { model | equipment = t, name = t.name }, Cmd.none ) + ( { model + | equipment = t + , name = t.name + , notes = t.notes + } + , Cmd.none + ) SetName n -> ( { model | name = n }, Cmd.none ) + SetNotes str -> + ( { model | notes = Util.Maybe.fromString str }, Cmd.none ) + view : Model -> Html Msg view model = @@ -84,9 +101,7 @@ view model = view2 : Model -> Html Msg view2 model = div [ class "flex flex-col" ] - [ div - [ class "mb-4" - ] + [ div [ class "mb-4" ] [ label [ for "equipname" , class S.inputLabel @@ -109,4 +124,17 @@ view2 model = ] [] ] + , div [ class "mb-4" ] + [ h3 [ class S.header3 ] + [ text "Notes" + ] + , div [ class "" ] + [ textarea + [ onInput SetNotes + , Maybe.withDefault "" model.notes |> value + , class S.textAreaInput + ] + [] + ] + ] ] diff --git a/modules/webapp/src/main/elm/Comp/SearchMenu.elm b/modules/webapp/src/main/elm/Comp/SearchMenu.elm index 140147af..237c08e2 100644 --- a/modules/webapp/src/main/elm/Comp/SearchMenu.elm +++ b/modules/webapp/src/main/elm/Comp/SearchMenu.elm @@ -479,7 +479,7 @@ updateDrop ddm flags settings msg model = SetConcEquip id -> let equip = - Equipment id.id id.name 0 + Equipment id.id id.name 0 Nothing in resetAndSet (ConcEquipmentMsg (Comp.Dropdown.SetSelection [ equip ]))