Merge pull request #215 from eikek/add-meta-modal

Add meta modal
This commit is contained in:
mergify[bot] 2020-08-06 23:40:06 +00:00 committed by GitHub
commit 1d2b432e82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 442 additions and 24 deletions

View File

@ -11,6 +11,8 @@ trait OEquipment[F[_]] {
def findAll(account: AccountId, nameQuery: Option[String]): F[Vector[REquipment]] def findAll(account: AccountId, nameQuery: Option[String]): F[Vector[REquipment]]
def find(account: AccountId, id: Ident): F[Option[REquipment]]
def add(s: REquipment): F[AddResult] def add(s: REquipment): F[AddResult]
def update(s: REquipment): F[AddResult] def update(s: REquipment): F[AddResult]
@ -25,6 +27,9 @@ object OEquipment {
def findAll(account: AccountId, nameQuery: Option[String]): F[Vector[REquipment]] = def findAll(account: AccountId, nameQuery: Option[String]): F[Vector[REquipment]] =
store.transact(REquipment.findAll(account.collective, nameQuery, _.name)) store.transact(REquipment.findAll(account.collective, nameQuery, _.name))
def find(account: AccountId, id: Ident): F[Option[REquipment]] =
store.transact(REquipment.findById(id)).map(_.filter(_.cid == account.collective))
def add(e: REquipment): F[AddResult] = { def add(e: REquipment): F[AddResult] = {
def insert = REquipment.insert(e) def insert = REquipment.insert(e)
def exists = REquipment.existsByName(e.cid, e.name) def exists = REquipment.existsByName(e.cid, e.name)

View File

@ -11,6 +11,7 @@ import docspell.store.records._
trait OOrganization[F[_]] { trait OOrganization[F[_]] {
def findAllOrg(account: AccountId, query: Option[String]): F[Vector[OrgAndContacts]] def findAllOrg(account: AccountId, query: Option[String]): F[Vector[OrgAndContacts]]
def findOrg(account: AccountId, orgId: Ident): F[Option[OrgAndContacts]]
def findAllOrgRefs(account: AccountId, nameQuery: Option[String]): F[Vector[IdRef]] def findAllOrgRefs(account: AccountId, nameQuery: Option[String]): F[Vector[IdRef]]
@ -23,6 +24,8 @@ trait OOrganization[F[_]] {
query: Option[String] query: Option[String]
): F[Vector[PersonAndContacts]] ): F[Vector[PersonAndContacts]]
def findPerson(account: AccountId, persId: Ident): F[Option[PersonAndContacts]]
def findAllPersonRefs(account: AccountId, nameQuery: Option[String]): F[Vector[IdRef]] def findAllPersonRefs(account: AccountId, nameQuery: Option[String]): F[Vector[IdRef]]
def addPerson(s: PersonAndContacts): F[AddResult] def addPerson(s: PersonAndContacts): F[AddResult]
@ -53,6 +56,11 @@ object OOrganization {
.compile .compile
.toVector .toVector
def findOrg(account: AccountId, orgId: Ident): F[Option[OrgAndContacts]] =
store
.transact(QOrganization.getOrgAndContact(account.collective, orgId))
.map(_.map({ case (org, cont) => OrgAndContacts(org, cont) }))
def findAllOrgRefs( def findAllOrgRefs(
account: AccountId, account: AccountId,
nameQuery: Option[String] nameQuery: Option[String]
@ -75,6 +83,11 @@ object OOrganization {
.compile .compile
.toVector .toVector
def findPerson(account: AccountId, persId: Ident): F[Option[PersonAndContacts]] =
store
.transact(QOrganization.getPersonAndContact(account.collective, persId))
.map(_.map({ case (org, cont) => PersonAndContacts(org, cont) }))
def findAllPersonRefs( def findAllPersonRefs(
account: AccountId, account: AccountId,
nameQuery: Option[String] nameQuery: Option[String]

View File

@ -778,6 +778,23 @@ paths:
schema: schema:
$ref: "#/components/schemas/BasicResult" $ref: "#/components/schemas/BasicResult"
/sec/equipment/{id}: /sec/equipment/{id}:
get:
tags: [ Equipment ]
summary: Get details about a single equipment.
description: |
Loads one equipment by its id.
security:
- authTokenHeader: []
parameters:
- $ref: "#/components/parameters/id"
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/Equipment"
delete: delete:
tags: [ Equipment ] tags: [ Equipment ]
summary: Delete a equipment. summary: Delete a equipment.

View File

@ -1,5 +1,6 @@
package docspell.restserver.routes package docspell.restserver.routes
import cats.data.OptionT
import cats.effect._ import cats.effect._
import cats.implicits._ import cats.implicits._
@ -49,6 +50,12 @@ object EquipmentRoutes {
del <- backend.equipment.delete(id, user.account.collective) del <- backend.equipment.delete(id, user.account.collective)
resp <- Ok(basicResult(del, "Equipment deleted.")) resp <- Ok(basicResult(del, "Equipment deleted."))
} yield resp } yield resp
case GET -> Root / Ident(id) =>
(for {
equip <- OptionT(backend.equipment.find(user.account, id))
resp <- OptionT.liftF(Ok(mkEquipment(equip)))
} yield resp).getOrElseF(NotFound())
} }
} }
} }

View File

@ -1,5 +1,6 @@
package docspell.restserver.routes package docspell.restserver.routes
import cats.data.OptionT
import cats.effect._ import cats.effect._
import cats.implicits._ import cats.implicits._
@ -55,6 +56,12 @@ object OrganizationRoutes {
delOrg <- backend.organization.deleteOrg(id, user.account.collective) delOrg <- backend.organization.deleteOrg(id, user.account.collective)
resp <- Ok(basicResult(delOrg, "Organization deleted.")) resp <- Ok(basicResult(delOrg, "Organization deleted."))
} yield resp } yield resp
case GET -> Root / Ident(id) =>
(for {
org <- OptionT(backend.organization.findOrg(user.account, id))
resp <- OptionT.liftF(Ok(mkOrg(org)))
} yield resp).getOrElseF(NotFound())
} }
} }

View File

@ -1,5 +1,6 @@
package docspell.restserver.routes package docspell.restserver.routes
import cats.data.OptionT
import cats.effect._ import cats.effect._
import cats.implicits._ import cats.implicits._
@ -59,6 +60,12 @@ object PersonRoutes {
delOrg <- backend.organization.deletePerson(id, user.account.collective) delOrg <- backend.organization.deletePerson(id, user.account.collective)
resp <- Ok(basicResult(delOrg, "Person deleted.")) resp <- Ok(basicResult(delOrg, "Person deleted."))
} yield resp } yield resp
case GET -> Root / Ident(id) =>
(for {
org <- OptionT(backend.organization.findPerson(user.account, id))
resp <- OptionT.liftF(Ok(mkPerson(org)))
} yield resp).getOrElseF(NotFound())
} }
} }

View File

@ -52,6 +52,34 @@ object QOrganization {
}) })
} }
def getOrgAndContact(
coll: Ident,
orgId: Ident
): ConnectionIO[Option[(ROrganization, Vector[RContact])]] = {
val oColl = ROrganization.Columns.cid.prefix("o")
val oId = ROrganization.Columns.oid.prefix("o")
val cOrg = RContact.Columns.orgId.prefix("c")
val cols = ROrganization.Columns.all.map(_.prefix("o")) ++ RContact.Columns.all
.map(_.prefix("c"))
val from = ROrganization.table ++ fr"o LEFT JOIN" ++
RContact.table ++ fr"c ON" ++ cOrg.is(oId)
val q = and(oColl.is(coll), oId.is(orgId))
selectSimple(cols, from, q)
.query[(ROrganization, Option[RContact])]
.stream
.groupAdjacentBy(_._1)
.map({
case (ro, chunk) =>
val cs = chunk.toVector.flatMap(_._2)
(ro, cs)
})
.compile
.last
}
def findPersonAndContact( def findPersonAndContact(
coll: Ident, coll: Ident,
query: Option[String], query: Option[String],
@ -88,6 +116,34 @@ object QOrganization {
}) })
} }
def getPersonAndContact(
coll: Ident,
persId: Ident
): ConnectionIO[Option[(RPerson, Vector[RContact])]] = {
val pColl = PC.cid.prefix("p")
val pId = RPerson.Columns.pid.prefix("p")
val cPers = RContact.Columns.personId.prefix("c")
val cols = RPerson.Columns.all.map(_.prefix("p")) ++ RContact.Columns.all
.map(_.prefix("c"))
val from = RPerson.table ++ fr"p LEFT JOIN" ++
RContact.table ++ fr"c ON" ++ cPers.is(pId)
val q = and(pColl.is(coll), pId.is(persId))
selectSimple(cols, from, q)
.query[(RPerson, Option[RContact])]
.stream
.groupAdjacentBy(_._1)
.map({
case (ro, chunk) =>
val cs = chunk.toVector.flatMap(_._2)
(ro, cs)
})
.compile
.last
}
def findPersonByContact( def findPersonByContact(
coll: Ident, coll: Ident,
value: String, value: String,

View File

@ -1,8 +1,10 @@
package docspell.store.records package docspell.store.records
import cats.data.NonEmptyList
import docspell.common._ import docspell.common._
import docspell.store.impl.Implicits._ import docspell.store.impl.Implicits._
import cats.data.NonEmptyList
import doobie._ import doobie._
import doobie.implicits._ import doobie.implicits._

View File

@ -31,6 +31,7 @@ module Api exposing
, getCollective , getCollective
, getCollectiveSettings , getCollectiveSettings
, getContacts , getContacts
, getEquipment
, getEquipments , getEquipments
, getFolderDetail , getFolderDetail
, getFolders , getFolders
@ -41,8 +42,10 @@ module Api exposing
, getJobQueueStateIn , getJobQueueStateIn
, getMailSettings , getMailSettings
, getNotifyDueItems , getNotifyDueItems
, getOrgFull
, getOrgLight , getOrgLight
, getOrganizations , getOrganizations
, getPersonFull
, getPersons , getPersons
, getPersonsLight , getPersonsLight
, getScanMailbox , getScanMailbox
@ -903,6 +906,15 @@ getEquipments flags query receive =
} }
getEquipment : Flags -> String -> (Result Http.Error Equipment -> msg) -> Cmd msg
getEquipment flags id receive =
Http2.authGet
{ url = flags.config.baseUrl ++ "/api/v1/sec/equipment/" ++ id
, account = getAccount flags
, expect = Http.expectJson receive Api.Model.Equipment.decoder
}
postEquipment : Flags -> Equipment -> (Result Http.Error BasicResult -> msg) -> Cmd msg postEquipment : Flags -> Equipment -> (Result Http.Error BasicResult -> msg) -> Cmd msg
postEquipment flags equip receive = postEquipment flags equip receive =
let let
@ -942,6 +954,15 @@ getOrgLight flags receive =
} }
getOrgFull : String -> Flags -> (Result Http.Error Organization -> msg) -> Cmd msg
getOrgFull id flags receive =
Http2.authGet
{ url = flags.config.baseUrl ++ "/api/v1/sec/organization/" ++ id
, account = getAccount flags
, expect = Http.expectJson receive Api.Model.Organization.decoder
}
getOrganizations : Flags -> String -> (Result Http.Error OrganizationList -> msg) -> Cmd msg getOrganizations : Flags -> String -> (Result Http.Error OrganizationList -> msg) -> Cmd msg
getOrganizations flags query receive = getOrganizations flags query receive =
Http2.authGet Http2.authGet
@ -990,6 +1011,15 @@ getPersonsLight flags receive =
} }
getPersonFull : String -> Flags -> (Result Http.Error Person -> msg) -> Cmd msg
getPersonFull id flags receive =
Http2.authGet
{ url = flags.config.baseUrl ++ "/api/v1/sec/person/" ++ id
, account = getAccount flags
, expect = Http.expectJson receive Api.Model.Person.decoder
}
getPersons : Flags -> String -> (Result Http.Error PersonList -> msg) -> Cmd msg getPersons : Flags -> String -> (Result Http.Error PersonList -> msg) -> Cmd msg
getPersons flags query receive = getPersons flags query receive =
Http2.authGet Http2.authGet

View File

@ -5,6 +5,7 @@ module Comp.ContactField exposing
, getContacts , getContacts
, update , update
, view , view
, view1
) )
import Api.Model.Contact exposing (Contact) import Api.Model.Contact exposing (Contact)
@ -81,9 +82,15 @@ update msg model =
Comp.Dropdown.getSelected model.kind Comp.Dropdown.getSelected model.kind
|> List.head |> List.head
|> Maybe.map Data.ContactType.toString |> Maybe.map Data.ContactType.toString
|> Maybe.withDefault ""
in in
( { model | items = Contact "" model.value kind :: model.items, value = "" }, Cmd.none ) case kind of
Just k ->
( { model | items = Contact "" model.value k :: model.items, value = "" }
, Cmd.none
)
Nothing ->
( model, Cmd.none )
Select contact -> Select contact ->
let let
@ -100,12 +107,27 @@ update msg model =
view : UiSettings -> Model -> Html Msg view : UiSettings -> Model -> Html Msg
view settings model = view settings model =
view1 settings False model
view1 : UiSettings -> Bool -> Model -> Html Msg
view1 settings compact model =
div [] div []
[ div [ class "fields" ] [ div [ classList [ ( "fields", not compact ) ] ]
[ div [ class "four wide field" ] [ div
[ classList
[ ( "field", True )
, ( "four wide", not compact )
]
]
[ Html.map TypeMsg (Comp.Dropdown.view settings model.kind) [ Html.map TypeMsg (Comp.Dropdown.view settings model.kind)
] ]
, div [ class "twelve wide field" ] , div
[ classList
[ ( "twelve wide", not compact )
, ( "field", True )
]
]
[ div [ class "ui action input" ] [ div [ class "ui action input" ]
[ input [ input
[ type_ "text" [ type_ "text"

View File

@ -2,6 +2,9 @@ module Comp.DetailEdit exposing
( Model ( Model
, Msg , Msg
, Value(..) , Value(..)
, editEquip
, editOrg
, editPerson
, initConcPerson , initConcPerson
, initCorrPerson , initCorrPerson
, initEquip , initEquip
@ -44,6 +47,7 @@ type alias Model =
{ form : FormModel { form : FormModel
, itemId : String , itemId : String
, submitting : Bool , submitting : Bool
, loading : Bool
, result : Maybe BasicResult , result : Maybe BasicResult
} }
@ -86,6 +90,7 @@ init itemId fm =
{ form = fm { form = fm
, itemId = itemId , itemId = itemId
, submitting = False , submitting = False
, loading = False
, result = Nothing , result = Nothing
} }
@ -100,6 +105,42 @@ initOrg itemId om =
init itemId (OM om) init itemId (OM om)
editOrg : Flags -> String -> Comp.OrgForm.Model -> ( Model, Cmd Msg )
editOrg flags orgId om =
( { form = OM om
, itemId = ""
, submitting = False
, loading = True
, result = Nothing
}
, Api.getOrgFull orgId flags GetOrgResp
)
editPerson : Flags -> String -> Comp.PersonForm.Model -> ( Model, Cmd Msg )
editPerson flags persId pm =
( { form = PMC pm
, itemId = ""
, submitting = False
, loading = True
, result = Nothing
}
, Api.getPersonFull persId flags GetPersonResp
)
editEquip : Flags -> String -> Comp.EquipmentForm.Model -> ( Model, Cmd Msg )
editEquip flags equipId em =
( { form = EM em
, itemId = ""
, submitting = False
, loading = True
, result = Nothing
}
, Api.getEquipment flags equipId GetEquipResp
)
initCorrPerson : String -> Comp.PersonForm.Model -> Model initCorrPerson : String -> Comp.PersonForm.Model -> Model
initCorrPerson itemId pm = initCorrPerson itemId pm =
init itemId (PMR pm) init itemId (PMR pm)
@ -135,6 +176,9 @@ type Msg
| Submit | Submit
| Cancel | Cancel
| SubmitResp (Result Http.Error BasicResult) | SubmitResp (Result Http.Error BasicResult)
| GetOrgResp (Result Http.Error Organization)
| GetPersonResp (Result Http.Error Person)
| GetEquipResp (Result Http.Error Equipment)
type Value type Value
@ -174,6 +218,87 @@ update flags msg model =
Cancel -> Cancel ->
( model, Cmd.none, Just CancelForm ) ( model, Cmd.none, Just CancelForm )
GetOrgResp (Ok org) ->
case model.form of
OM om ->
let
( om_, oc_ ) =
Comp.OrgForm.update flags (Comp.OrgForm.SetOrg org) om
in
( { model
| loading = False
, form = OM om_
}
, Cmd.map OrgMsg oc_
, Nothing
)
_ ->
( { model | loading = False }
, Cmd.none
, Nothing
)
GetOrgResp (Err err) ->
( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) }
, Cmd.none
, Nothing
)
GetPersonResp (Ok pers) ->
case model.form of
PMC pm ->
let
( pm_, pc_ ) =
Comp.PersonForm.update flags (Comp.PersonForm.SetPerson pers) pm
in
( { model
| loading = False
, form = PMC pm_
}
, Cmd.map PersonMsg pc_
, Nothing
)
_ ->
( { model | loading = False }
, Cmd.none
, Nothing
)
GetPersonResp (Err err) ->
( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) }
, Cmd.none
, Nothing
)
GetEquipResp (Ok equip) ->
case model.form of
EM em ->
let
( em_, ec_ ) =
Comp.EquipmentForm.update flags (Comp.EquipmentForm.SetEquipment equip) em
in
( { model
| loading = False
, form = EM em_
}
, Cmd.map EquipMsg ec_
, Nothing
)
_ ->
( { model | loading = False }
, Cmd.none
, Nothing
)
GetEquipResp (Err err) ->
( { model | loading = False, result = Just (BasicResult False (Util.Http.errorToString err)) }
, Cmd.none
, Nothing
)
SubmitResp (Ok res) -> SubmitResp (Ok res) ->
( { model ( { model
| result = Just res | result = Just res
@ -222,7 +347,11 @@ update flags msg model =
in in
if Comp.OrgForm.isValid om then if Comp.OrgForm.isValid om then
( { model | submitting = True } ( { model | submitting = True }
, Api.addCorrOrg flags model.itemId org SubmitResp , if model.itemId == "" then
Api.postOrg flags org SubmitResp
else
Api.addCorrOrg flags model.itemId org SubmitResp
, Nothing , Nothing
) )
@ -239,7 +368,11 @@ update flags msg model =
in in
if Comp.PersonForm.isValid pm then if Comp.PersonForm.isValid pm then
( { model | submitting = True } ( { model | submitting = True }
, Api.addConcPerson flags model.itemId pers SubmitResp , if model.itemId == "" then
Api.postPerson flags pers SubmitResp
else
Api.addConcPerson flags model.itemId pers SubmitResp
, Nothing , Nothing
) )
@ -256,7 +389,11 @@ update flags msg model =
in in
if Comp.PersonForm.isValid pm then if Comp.PersonForm.isValid pm then
( { model | submitting = True } ( { model | submitting = True }
, Api.addCorrPerson flags model.itemId pers SubmitResp , if model.itemId == "" then
Api.postPerson flags pers SubmitResp
else
Api.addCorrPerson flags model.itemId pers SubmitResp
, Nothing , Nothing
) )
@ -273,7 +410,11 @@ update flags msg model =
in in
if Comp.EquipmentForm.isValid em then if Comp.EquipmentForm.isValid em then
( { model | submitting = True } ( { model | submitting = True }
, Api.addConcEquip flags model.itemId equip SubmitResp , if model.itemId == "" then
Api.postEquipment flags equip SubmitResp
else
Api.addConcEquip flags model.itemId equip SubmitResp
, Nothing , Nothing
) )
@ -379,9 +520,9 @@ viewButtons model =
[ class "ui primary button" [ class "ui primary button"
, href "#" , href "#"
, onClick Submit , onClick Submit
, disabled model.submitting , disabled (model.submitting || model.loading)
] ]
[ if model.submitting then [ if model.submitting || model.loading then
i [ class "ui spinner loading icon" ] [] i [ class "ui spinner loading icon" ] []
else else
@ -416,13 +557,13 @@ viewIntern settings withButtons model =
Html.map TagMsg (Comp.TagForm.view tm) Html.map TagMsg (Comp.TagForm.view tm)
PMR pm -> PMR pm ->
Html.map PersonMsg (Comp.PersonForm.view settings pm) Html.map PersonMsg (Comp.PersonForm.view1 settings True pm)
PMC pm -> PMC pm ->
Html.map PersonMsg (Comp.PersonForm.view settings pm) Html.map PersonMsg (Comp.PersonForm.view1 settings True pm)
OM om -> OM om ->
Html.map OrgMsg (Comp.OrgForm.view settings om) Html.map OrgMsg (Comp.OrgForm.view1 settings True om)
EM em -> EM em ->
Html.map EquipMsg (Comp.EquipmentForm.view em) Html.map EquipMsg (Comp.EquipmentForm.view em)
@ -461,13 +602,18 @@ viewModal settings mm =
in in
div div
[ classList [ classList
[ ( "ui inverted modals page dimmer", True ) [ ( "ui inverted dimmer", True )
, ( "invisibe hidden", hidden ) , ( "invisibe hidden", hidden )
, ( "active", not hidden ) , ( "active", not hidden )
] ]
, style "display" "flex !important" , style "display" "flex !important"
] ]
[ div [ class "ui modal active" ] [ div
[ classList
[ ( "ui modal keep-small", True )
, ( "active", not hidden )
]
]
[ div [ class "header" ] [ div [ class "header" ]
[ Maybe.map .form mm [ Maybe.map .form mm
|> Maybe.map headIcon |> Maybe.map headIcon

View File

@ -9,6 +9,7 @@ module Comp.Dropdown exposing
, makeSingle , makeSingle
, makeSingleList , makeSingleList
, mkOption , mkOption
, notSelected
, setMkOption , setMkOption
, update , update
, view , view
@ -155,6 +156,11 @@ getSelected model =
List.map .value model.selected List.map .value model.selected
notSelected : Model a -> Bool
notSelected model =
getSelected model |> List.isEmpty
type Msg a type Msg a
= SetOptions (List a) = SetOptions (List a)
| SetSelection (List a) | SetSelection (List a)

View File

@ -122,6 +122,9 @@ type Msg
| EditAttachNameResp (Result Http.Error BasicResult) | EditAttachNameResp (Result Http.Error BasicResult)
| GetFolderResp (Result Http.Error FolderList) | GetFolderResp (Result Http.Error FolderList)
| FolderDropdownMsg (Comp.Dropdown.Msg IdName) | FolderDropdownMsg (Comp.Dropdown.Msg IdName)
| StartEditCorrOrgModal
| StartEditPersonModal (Comp.Dropdown.Model IdName)
| StartEditEquipModal
update : Nav.Key -> Flags -> Maybe String -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg ) update : Nav.Key -> Flags -> Maybe String -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
@ -1046,6 +1049,42 @@ update key flags next msg model =
, Cmd.none , Cmd.none
) )
StartEditCorrOrgModal ->
let
orgId =
Comp.Dropdown.getSelected model.corrOrgModel
|> List.head
|> Maybe.map .id
in
case orgId of
Just oid ->
let
( m, c ) =
Comp.DetailEdit.editOrg flags oid Comp.OrgForm.emptyModel
in
noSub ( { model | modalEdit = Just m }, Cmd.map ModalEditMsg c )
Nothing ->
( model, Cmd.none, Sub.none )
StartEditEquipModal ->
let
equipId =
Comp.Dropdown.getSelected model.concEquipModel
|> List.head
|> Maybe.map .id
in
case equipId of
Just eid ->
let
( m, c ) =
Comp.DetailEdit.editEquip flags eid Comp.EquipmentForm.emptyModel
in
noSub ( { model | modalEdit = Just m }, Cmd.map ModalEditMsg c )
Nothing ->
( model, Cmd.none, Sub.none )
StartCorrPersonModal -> StartCorrPersonModal ->
noSub noSub
( { model ( { model
@ -1072,6 +1111,24 @@ update key flags next msg model =
, Cmd.none , Cmd.none
) )
StartEditPersonModal pm ->
let
persId =
Comp.Dropdown.getSelected pm
|> List.head
|> Maybe.map .id
in
case persId of
Just pid ->
let
( m, c ) =
Comp.DetailEdit.editPerson flags pid Comp.PersonForm.emptyModel
in
noSub ( { model | modalEdit = Just m }, Cmd.map ModalEditMsg c )
Nothing ->
( model, Cmd.none, Sub.none )
StartEquipModal -> StartEquipModal ->
noSub noSub
( { model ( { model

View File

@ -6,7 +6,7 @@ import Comp.DatePicker
import Comp.DetailEdit import Comp.DetailEdit
import Comp.Dropdown import Comp.Dropdown
import Comp.Dropzone import Comp.Dropzone
import Comp.ItemDetail.Model exposing (Model, NotesField(..), isEditNotes) import Comp.ItemDetail.Model exposing (Model, NotesField(..))
import Comp.ItemDetail.Update exposing (Msg(..)) import Comp.ItemDetail.Update exposing (Msg(..))
import Comp.ItemMail import Comp.ItemMail
import Comp.MarkdownInput import Comp.MarkdownInput
@ -37,8 +37,7 @@ import Util.Time
view : { prev : Maybe String, next : Maybe String } -> UiSettings -> Model -> Html Msg view : { prev : Maybe String, next : Maybe String } -> UiSettings -> Model -> Html Msg
view inav settings model = view inav settings model =
div [] div []
[ Html.map ModalEditMsg (Comp.DetailEdit.viewModal settings model.modalEdit) [ renderItemInfo settings model
, renderItemInfo settings model
, renderDetailMenu inav model , renderDetailMenu inav model
, renderMailForm settings model , renderMailForm settings model
, renderAddFilesForm model , renderAddFilesForm model
@ -684,7 +683,8 @@ renderTags settings model =
renderEditMenu : UiSettings -> Model -> List (Html Msg) renderEditMenu : UiSettings -> Model -> List (Html Msg)
renderEditMenu settings model = renderEditMenu settings model =
[ div [ class "ui segments" ] [ Html.map ModalEditMsg (Comp.DetailEdit.viewModal settings model.modalEdit)
, div []
[ renderEditButtons model [ renderEditButtons model
, renderEditForm settings model , renderEditForm settings model
] ]
@ -741,8 +741,21 @@ renderEditForm settings model =
] ]
[ i [ class "grey plus link icon" ] [] [ i [ class "grey plus link icon" ] []
] ]
editIconLink tip dm m =
a
[ classList
[ ( "right-float", True )
, ( "invisible hidden", Comp.Dropdown.notSelected dm )
]
, href "#"
, title tip
, onClick m
]
[ i [ class "grey pencil alternate link icon" ] []
]
in in
div [ class "ui segment" ] div [ class "ui attached segment" ]
[ div [ class "ui form warning" ] [ div [ class "ui form warning" ]
[ div [ class "field" ] [ div [ class "field" ]
[ label [] [ label []
@ -834,6 +847,7 @@ item visible. This message will disappear then.
[ Icons.organizationIcon "grey" [ Icons.organizationIcon "grey"
, text "Organization" , text "Organization"
, addIconLink "Add new organization" StartCorrOrgModal , addIconLink "Add new organization" StartCorrOrgModal
, editIconLink "Edit organization" model.corrOrgModel StartEditCorrOrgModal
] ]
, Html.map OrgDropdownMsg (Comp.Dropdown.view settings model.corrOrgModel) , Html.map OrgDropdownMsg (Comp.Dropdown.view settings model.corrOrgModel)
, renderOrgSuggestions model , renderOrgSuggestions model
@ -843,6 +857,9 @@ item visible. This message will disappear then.
[ Icons.personIcon "grey" [ Icons.personIcon "grey"
, text "Person" , text "Person"
, addIconLink "Add new correspondent person" StartCorrPersonModal , addIconLink "Add new correspondent person" StartCorrPersonModal
, editIconLink "Edit person"
model.corrPersonModel
(StartEditPersonModal model.corrPersonModel)
] ]
, Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel) , Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
, renderCorrPersonSuggestions model , renderCorrPersonSuggestions model
@ -856,6 +873,9 @@ item visible. This message will disappear then.
[ Icons.personIcon "grey" [ Icons.personIcon "grey"
, text "Person" , text "Person"
, addIconLink "Add new concerning person" StartConcPersonModal , addIconLink "Add new concerning person" StartConcPersonModal
, editIconLink "Edit person"
model.concPersonModel
(StartEditPersonModal model.concPersonModel)
] ]
, Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel) , Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
, renderConcPersonSuggestions model , renderConcPersonSuggestions model
@ -865,6 +885,9 @@ item visible. This message will disappear then.
[ Icons.equipmentIcon "grey" [ Icons.equipmentIcon "grey"
, text "Equipment" , text "Equipment"
, addIconLink "Add new equipment" StartEquipModal , addIconLink "Add new equipment" StartEquipModal
, editIconLink "Edit equipment"
model.concEquipModel
StartEditEquipModal
] ]
, Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel) , Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel)
, renderConcEquipSuggestions model , renderConcEquipSuggestions model

View File

@ -6,6 +6,7 @@ module Comp.OrgForm exposing
, isValid , isValid
, update , update
, view , view
, view1
) )
import Api.Model.Organization exposing (Organization) import Api.Model.Organization exposing (Organization)
@ -109,6 +110,11 @@ update flags msg model =
view : UiSettings -> Model -> Html Msg view : UiSettings -> Model -> Html Msg
view settings model = view settings model =
view1 settings False model
view1 : UiSettings -> Bool -> Model -> Html Msg
view1 settings compact model =
div [ class "ui form" ] div [ class "ui form" ]
[ div [ div
[ classList [ classList
@ -132,7 +138,7 @@ view settings model =
, h3 [ class "ui dividing header" ] , h3 [ class "ui dividing header" ]
[ text "Contacts" [ text "Contacts"
] ]
, Html.map ContactMsg (Comp.ContactField.view settings model.contactModel) , Html.map ContactMsg (Comp.ContactField.view1 settings compact model.contactModel)
, h3 [ class "ui dividing header" ] , h3 [ class "ui dividing header" ]
[ text "Notes" [ text "Notes"
] ]

View File

@ -6,6 +6,7 @@ module Comp.PersonForm exposing
, isValid , isValid
, update , update
, view , view
, view1
) )
import Api.Model.Person exposing (Person) import Api.Model.Person exposing (Person)
@ -123,6 +124,11 @@ update flags msg model =
view : UiSettings -> Model -> Html Msg view : UiSettings -> Model -> Html Msg
view settings model = view settings model =
view1 settings False model
view1 : UiSettings -> Bool -> Model -> Html Msg
view1 settings compact model =
div [ class "ui form" ] div [ class "ui form" ]
[ div [ div
[ classList [ classList
@ -157,7 +163,7 @@ view settings model =
, h3 [ class "ui dividing header" ] , h3 [ class "ui dividing header" ]
[ text "Contacts" [ text "Contacts"
] ]
, Html.map ContactMsg (Comp.ContactField.view settings model.contactModel) , Html.map ContactMsg (Comp.ContactField.view1 settings compact model.contactModel)
, h3 [ class "ui dividing header" ] , h3 [ class "ui dividing header" ]
[ text "Notes" [ text "Notes"
] ]

View File

@ -170,6 +170,14 @@ textarea.markdown-editor {
background: rgba(0,0,0,0.2); background: rgba(0,0,0,0.2);
} }
@media only screen and (min-width: 992px) {
.ui.modal.keep-small {
width: inherit;
margin: 0 0 0 1rem;
}
}
label span.muted { label span.muted {
font-size: smaller; font-size: smaller;
color: rgba(0,0,0,0.6); color: rgba(0,0,0,0.6);