mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-07 07:35:59 +00:00
Add a short-name to organizations
This commit is contained in:
parent
20ccdda609
commit
5181283b1b
@ -5069,6 +5069,8 @@ components:
|
|||||||
description: DateTime
|
description: DateTime
|
||||||
type: integer
|
type: integer
|
||||||
format: date-time
|
format: date-time
|
||||||
|
shortName:
|
||||||
|
type: string
|
||||||
OrganizationList:
|
OrganizationList:
|
||||||
description: |
|
description: |
|
||||||
A list of full organization values.
|
A list of full organization values.
|
||||||
|
@ -386,7 +386,8 @@ trait Conversions {
|
|||||||
Address(ro.street, ro.zip, ro.city, ro.country),
|
Address(ro.street, ro.zip, ro.city, ro.country),
|
||||||
v.contacts.map(mkContact).toList,
|
v.contacts.map(mkContact).toList,
|
||||||
ro.notes,
|
ro.notes,
|
||||||
ro.created
|
ro.created,
|
||||||
|
ro.shortName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,7 +408,8 @@ trait Conversions {
|
|||||||
v.address.country,
|
v.address.country,
|
||||||
v.notes,
|
v.notes,
|
||||||
now,
|
now,
|
||||||
now
|
now,
|
||||||
|
v.shortName
|
||||||
)
|
)
|
||||||
} yield OOrganization.OrgAndContacts(org, cont)
|
} yield OOrganization.OrgAndContacts(org, cont)
|
||||||
}
|
}
|
||||||
@ -431,7 +433,8 @@ trait Conversions {
|
|||||||
v.address.country,
|
v.address.country,
|
||||||
v.notes,
|
v.notes,
|
||||||
v.created,
|
v.created,
|
||||||
now
|
now,
|
||||||
|
v.shortName
|
||||||
)
|
)
|
||||||
} yield OOrganization.OrgAndContacts(org, cont)
|
} yield OOrganization.OrgAndContacts(org, cont)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE "organization"
|
||||||
|
ADD COLUMN "short_name" varchar(254);
|
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE `organization`
|
||||||
|
ADD COLUMN `short_name` varchar(254);
|
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE "organization"
|
||||||
|
ADD COLUMN "short_name" varchar(254);
|
@ -25,7 +25,7 @@ object QOrganization {
|
|||||||
): Stream[ConnectionIO, (ROrganization, Vector[RContact])] = {
|
): Stream[ConnectionIO, (ROrganization, Vector[RContact])] = {
|
||||||
val valFilter = query.map { q =>
|
val valFilter = query.map { q =>
|
||||||
val v = s"%$q%"
|
val v = s"%$q%"
|
||||||
c.value.like(v) || org.name.like(v) || org.notes.like(v)
|
c.value.like(v) || org.name.like(v) || org.shortName.like(v) || org.notes.like(v)
|
||||||
}
|
}
|
||||||
val sql = Select(
|
val sql = Select(
|
||||||
select(org.all, c.all),
|
select(org.all, c.all),
|
||||||
|
@ -21,7 +21,8 @@ case class ROrganization(
|
|||||||
country: String,
|
country: String,
|
||||||
notes: Option[String],
|
notes: Option[String],
|
||||||
created: Timestamp,
|
created: Timestamp,
|
||||||
updated: Timestamp
|
updated: Timestamp,
|
||||||
|
shortName: Option[String]
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
object ROrganization {
|
object ROrganization {
|
||||||
@ -41,6 +42,7 @@ object ROrganization {
|
|||||||
val notes = Column[String]("notes", this)
|
val notes = Column[String]("notes", this)
|
||||||
val created = Column[Timestamp]("created", this)
|
val created = Column[Timestamp]("created", this)
|
||||||
val updated = Column[Timestamp]("updated", this)
|
val updated = Column[Timestamp]("updated", this)
|
||||||
|
val shortName = Column[String]("short_name", this)
|
||||||
val all =
|
val all =
|
||||||
NonEmptyList.of[Column[_]](
|
NonEmptyList.of[Column[_]](
|
||||||
oid,
|
oid,
|
||||||
@ -52,7 +54,8 @@ object ROrganization {
|
|||||||
country,
|
country,
|
||||||
notes,
|
notes,
|
||||||
created,
|
created,
|
||||||
updated
|
updated,
|
||||||
|
shortName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +67,7 @@ object ROrganization {
|
|||||||
DML.insert(
|
DML.insert(
|
||||||
T,
|
T,
|
||||||
T.all,
|
T.all,
|
||||||
fr"${v.oid},${v.cid},${v.name},${v.street},${v.zip},${v.city},${v.country},${v.notes},${v.created},${v.updated}"
|
fr"${v.oid},${v.cid},${v.name},${v.street},${v.zip},${v.city},${v.country},${v.notes},${v.created},${v.updated},${v.shortName}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def update(v: ROrganization): ConnectionIO[Int] = {
|
def update(v: ROrganization): ConnectionIO[Int] = {
|
||||||
@ -80,7 +83,8 @@ object ROrganization {
|
|||||||
T.city.setTo(v.city),
|
T.city.setTo(v.city),
|
||||||
T.country.setTo(v.country),
|
T.country.setTo(v.country),
|
||||||
T.notes.setTo(v.notes),
|
T.notes.setTo(v.notes),
|
||||||
T.updated.setTo(now)
|
T.updated.setTo(now),
|
||||||
|
T.shortName.setTo(v.shortName)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
for {
|
for {
|
||||||
@ -106,7 +110,11 @@ object ROrganization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def findLike(coll: Ident, orgName: String): ConnectionIO[Vector[IdRef]] =
|
def findLike(coll: Ident, orgName: String): ConnectionIO[Vector[IdRef]] =
|
||||||
run(select(T.oid, T.name), from(T), T.cid === coll && T.name.like(orgName))
|
run(
|
||||||
|
select(T.oid, T.name),
|
||||||
|
from(T),
|
||||||
|
T.cid === coll && (T.name.like(orgName) || T.shortName.like(orgName))
|
||||||
|
)
|
||||||
.query[IdRef]
|
.query[IdRef]
|
||||||
.to[Vector]
|
.to[Vector]
|
||||||
|
|
||||||
@ -141,7 +149,9 @@ object ROrganization {
|
|||||||
nameQ: Option[String],
|
nameQ: Option[String],
|
||||||
order: Table => Column[_]
|
order: Table => Column[_]
|
||||||
): ConnectionIO[Vector[IdRef]] = {
|
): ConnectionIO[Vector[IdRef]] = {
|
||||||
val nameFilter = nameQ.map(s => T.name.like(s"%${s.toLowerCase}%"))
|
val nameFilter = nameQ.map(s =>
|
||||||
|
T.name.like(s"%${s.toLowerCase}%") || T.shortName.like(s"%${s.toLowerCase}%")
|
||||||
|
)
|
||||||
val sql = Select(select(T.oid, T.name), from(T), T.cid === coll &&? nameFilter)
|
val sql = Select(select(T.oid, T.name), from(T), T.cid === coll &&? nameFilter)
|
||||||
.orderBy(order(T))
|
.orderBy(order(T))
|
||||||
sql.build.query[IdRef].to[Vector]
|
sql.build.query[IdRef].to[Vector]
|
||||||
|
@ -20,6 +20,7 @@ import Html exposing (..)
|
|||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (onInput)
|
import Html.Events exposing (onInput)
|
||||||
import Styles as S
|
import Styles as S
|
||||||
|
import Util.Maybe
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
@ -28,6 +29,7 @@ type alias Model =
|
|||||||
, addressModel : Comp.AddressForm.Model
|
, addressModel : Comp.AddressForm.Model
|
||||||
, contactModel : Comp.ContactField.Model
|
, contactModel : Comp.ContactField.Model
|
||||||
, notes : Maybe String
|
, notes : Maybe String
|
||||||
|
, shortName : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -38,6 +40,7 @@ emptyModel =
|
|||||||
, addressModel = Comp.AddressForm.emptyModel
|
, addressModel = Comp.AddressForm.emptyModel
|
||||||
, contactModel = Comp.ContactField.emptyModel
|
, contactModel = Comp.ContactField.emptyModel
|
||||||
, notes = Nothing
|
, notes = Nothing
|
||||||
|
, shortName = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -57,6 +60,7 @@ getOrg model =
|
|||||||
, address = Comp.AddressForm.getAddress model.addressModel
|
, address = Comp.AddressForm.getAddress model.addressModel
|
||||||
, contacts = Comp.ContactField.getContacts model.contactModel
|
, contacts = Comp.ContactField.getContacts model.contactModel
|
||||||
, notes = model.notes
|
, notes = model.notes
|
||||||
|
, shortName = model.shortName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -66,6 +70,7 @@ type Msg
|
|||||||
| AddressMsg Comp.AddressForm.Msg
|
| AddressMsg Comp.AddressForm.Msg
|
||||||
| ContactMsg Comp.ContactField.Msg
|
| ContactMsg Comp.ContactField.Msg
|
||||||
| SetNotes String
|
| SetNotes String
|
||||||
|
| SetShortName String
|
||||||
|
|
||||||
|
|
||||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||||
@ -79,7 +84,14 @@ update flags msg model =
|
|||||||
( m2, c2 ) =
|
( m2, c2 ) =
|
||||||
update flags (ContactMsg (Comp.ContactField.SetItems t.contacts)) m1
|
update flags (ContactMsg (Comp.ContactField.SetItems t.contacts)) m1
|
||||||
in
|
in
|
||||||
( { m2 | org = t, name = t.name, notes = t.notes }, Cmd.batch [ c1, c2 ] )
|
( { m2
|
||||||
|
| org = t
|
||||||
|
, name = t.name
|
||||||
|
, notes = t.notes
|
||||||
|
, shortName = t.shortName
|
||||||
|
}
|
||||||
|
, Cmd.batch [ c1, c2 ]
|
||||||
|
)
|
||||||
|
|
||||||
AddressMsg am ->
|
AddressMsg am ->
|
||||||
let
|
let
|
||||||
@ -99,14 +111,12 @@ update flags msg model =
|
|||||||
( { model | name = n }, Cmd.none )
|
( { model | name = n }, Cmd.none )
|
||||||
|
|
||||||
SetNotes str ->
|
SetNotes str ->
|
||||||
( { model
|
( { model | notes = Util.Maybe.fromString str }
|
||||||
| notes =
|
, Cmd.none
|
||||||
if str == "" then
|
)
|
||||||
Nothing
|
|
||||||
|
|
||||||
else
|
SetShortName str ->
|
||||||
Just str
|
( { model | shortName = Util.Maybe.fromString str }
|
||||||
}
|
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -184,6 +194,25 @@ view2 mobile settings model =
|
|||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
]
|
]
|
||||||
|
, div
|
||||||
|
[ class "mb-4" ]
|
||||||
|
[ label
|
||||||
|
[ for "org-short-name"
|
||||||
|
, class S.inputLabel
|
||||||
|
]
|
||||||
|
[ text "Short Name"
|
||||||
|
]
|
||||||
|
, input
|
||||||
|
[ type_ "text"
|
||||||
|
, onInput SetShortName
|
||||||
|
, placeholder "Abbreviation"
|
||||||
|
, Maybe.withDefault "" model.shortName
|
||||||
|
|> value
|
||||||
|
, name "org-short-name"
|
||||||
|
, class S.textInput
|
||||||
|
]
|
||||||
|
[]
|
||||||
|
]
|
||||||
, div [ class "mb-4" ]
|
, div [ class "mb-4" ]
|
||||||
[ h3 [ class S.header3 ]
|
[ h3 [ class S.header3 ]
|
||||||
[ text "Address"
|
[ text "Address"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user