mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Link shares to the user, not the collective
The user is required when searching because of folders (sadly), so the share is connected to the user.
This commit is contained in:
23
modules/webapp/package-lock.json
generated
23
modules/webapp/package-lock.json
generated
@ -153,20 +153,8 @@
|
||||
"electron-to-chromium": "^1.3.719",
|
||||
"escalade": "^3.1.1",
|
||||
"node-releases": "^1.1.71"
|
||||
},
|
||||
"dependencies": {
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001230",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001230.tgz",
|
||||
"integrity": "sha512-5yBd5nWCBS+jWKTcHOzXwo5xzcj4ePE/yjtkZyUV1BTUmrBaA9MRGC+e7mxnqXSA90CmCA8L3eKLaSUkt099IQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001204",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001204.tgz",
|
||||
"integrity": "sha512-JUdjWpcxfJ9IPamy2f5JaRDCaqJOxDzOSKtbdx4rH9VivMd1vIzoPumsJa9LoMIi4Fx2BV2KZOxWhNkBjaYivQ=="
|
||||
},
|
||||
"colorette": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.2.tgz",
|
||||
@ -228,11 +216,6 @@
|
||||
"node-releases": "^1.1.71"
|
||||
},
|
||||
"dependencies": {
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001230",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001230.tgz",
|
||||
"integrity": "sha512-5yBd5nWCBS+jWKTcHOzXwo5xzcj4ePE/yjtkZyUV1BTUmrBaA9MRGC+e7mxnqXSA90CmCA8L3eKLaSUkt099IQ=="
|
||||
},
|
||||
"colorette": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.2.tgz",
|
||||
@ -272,9 +255,9 @@
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001208",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001208.tgz",
|
||||
"integrity": "sha512-OE5UE4+nBOro8Dyvv0lfx+SRtfVIOM9uhKqFmJeUbGriqhhStgp1A0OyBpgy3OUF8AhYCT+PVwPC1gMl2ZcQMA=="
|
||||
"version": "1.0.30001271",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001271.tgz",
|
||||
"integrity": "sha512-BBruZFWmt3HFdVPS8kceTBIguKxu4f99n5JNp06OlPD/luoAMIaIK5ieV5YjnBLH3Nysai9sxj9rpJj4ZisXOA=="
|
||||
},
|
||||
"chalk": {
|
||||
"version": "2.4.2",
|
||||
|
@ -2228,10 +2228,19 @@ disableOtp flags otp receive =
|
||||
--- Share
|
||||
|
||||
|
||||
getShares : Flags -> (Result Http.Error ShareList -> msg) -> Cmd msg
|
||||
getShares flags receive =
|
||||
getShares : Flags -> String -> Bool -> (Result Http.Error ShareList -> msg) -> Cmd msg
|
||||
getShares flags query owning receive =
|
||||
Http2.authGet
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/sec/share"
|
||||
{ url =
|
||||
flags.config.baseUrl
|
||||
++ "/api/v1/sec/share?q="
|
||||
++ Url.percentEncode query
|
||||
++ (if owning then
|
||||
"&owning"
|
||||
|
||||
else
|
||||
""
|
||||
)
|
||||
, account = getAccount flags
|
||||
, expect = Http.expectJson receive Api.Model.ShareList.decoder
|
||||
}
|
||||
|
@ -56,6 +56,8 @@ type alias Model =
|
||||
, loading : Bool
|
||||
, formError : FormError
|
||||
, deleteConfirm : DeleteConfirm
|
||||
, query : String
|
||||
, owningOnly : Bool
|
||||
}
|
||||
|
||||
|
||||
@ -75,6 +77,8 @@ init flags =
|
||||
, loading = False
|
||||
, formError = FormErrorNone
|
||||
, deleteConfirm = DeleteConfirmOff
|
||||
, query = ""
|
||||
, owningOnly = True
|
||||
}
|
||||
, Cmd.batch
|
||||
[ Cmd.map FormMsg fc
|
||||
@ -90,6 +94,8 @@ type Msg
|
||||
| MailMsg Comp.ShareMail.Msg
|
||||
| InitNewShare
|
||||
| SetViewMode ViewMode
|
||||
| SetQuery String
|
||||
| ToggleOwningOnly
|
||||
| Submit
|
||||
| RequestDelete
|
||||
| CancelDelete
|
||||
@ -126,7 +132,7 @@ update texts flags msg model =
|
||||
SetViewMode vm ->
|
||||
( { model | viewMode = vm, formError = FormErrorNone }
|
||||
, if vm == Table then
|
||||
Api.getShares flags LoadSharesResp
|
||||
Api.getShares flags model.query model.owningOnly LoadSharesResp
|
||||
|
||||
else
|
||||
Cmd.none
|
||||
@ -165,7 +171,10 @@ update texts flags msg model =
|
||||
)
|
||||
|
||||
LoadShares ->
|
||||
( { model | loading = True }, Api.getShares flags LoadSharesResp, Sub.none )
|
||||
( { model | loading = True }
|
||||
, Api.getShares flags model.query model.owningOnly LoadSharesResp
|
||||
, Sub.none
|
||||
)
|
||||
|
||||
LoadSharesResp (Ok list) ->
|
||||
( { model | loading = False, shares = list.items, formError = FormErrorNone }
|
||||
@ -231,6 +240,26 @@ update texts flags msg model =
|
||||
in
|
||||
( { model | mailModel = mm }, Cmd.map MailMsg mc, Sub.none )
|
||||
|
||||
SetQuery q ->
|
||||
let
|
||||
nm =
|
||||
{ model | query = q }
|
||||
in
|
||||
( nm
|
||||
, Api.getShares flags nm.query nm.owningOnly LoadSharesResp
|
||||
, Sub.none
|
||||
)
|
||||
|
||||
ToggleOwningOnly ->
|
||||
let
|
||||
nm =
|
||||
{ model | owningOnly = not model.owningOnly }
|
||||
in
|
||||
( nm
|
||||
, Api.getShares flags nm.query nm.owningOnly LoadSharesResp
|
||||
, Sub.none
|
||||
)
|
||||
|
||||
|
||||
setShare : Texts -> ShareDetail -> Flags -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
setShare texts share flags model =
|
||||
@ -271,7 +300,19 @@ viewTable texts model =
|
||||
div [ class "flex flex-col" ]
|
||||
[ MB.view
|
||||
{ start =
|
||||
[]
|
||||
[ MB.TextInput
|
||||
{ tagger = SetQuery
|
||||
, value = model.query
|
||||
, placeholder = texts.basics.searchPlaceholder
|
||||
, icon = Just "fa fa-search"
|
||||
}
|
||||
, MB.Checkbox
|
||||
{ tagger = \_ -> ToggleOwningOnly
|
||||
, label = texts.showOwningSharesOnly
|
||||
, value = model.owningOnly
|
||||
, id = "share-toggle-owner"
|
||||
}
|
||||
]
|
||||
, end =
|
||||
[ MB.PrimaryButton
|
||||
{ tagger = InitNewShare
|
||||
@ -295,6 +336,11 @@ viewForm texts settings flags model =
|
||||
let
|
||||
newShare =
|
||||
model.formModel.share.id == ""
|
||||
|
||||
isOwner =
|
||||
Maybe.map .user flags.account
|
||||
|> Maybe.map ((==) model.formModel.share.owner.name)
|
||||
|> Maybe.withDefault False
|
||||
in
|
||||
div []
|
||||
[ Html.form []
|
||||
@ -305,20 +351,34 @@ viewForm texts settings flags model =
|
||||
|
||||
else
|
||||
h1 [ class S.header2 ]
|
||||
[ text <| Maybe.withDefault texts.noName model.formModel.share.name
|
||||
, div [ class "opacity-50 text-sm" ]
|
||||
[ text "Id: "
|
||||
, text model.formModel.share.id
|
||||
[ div [ class "flex flex-row items-center" ]
|
||||
[ div
|
||||
[ class "flex text-sm opacity-75 label mr-3"
|
||||
, classList [ ( "hidden", isOwner ) ]
|
||||
]
|
||||
[ i [ class "fa fa-user mr-2" ] []
|
||||
, text model.formModel.share.owner.name
|
||||
]
|
||||
, text <| Maybe.withDefault texts.noName model.formModel.share.name
|
||||
]
|
||||
, div [ class "flex flex-row items-center" ]
|
||||
[ div [ class "opacity-50 text-sm flex-grow" ]
|
||||
[ text "Id: "
|
||||
, text model.formModel.share.id
|
||||
]
|
||||
]
|
||||
]
|
||||
, MB.view
|
||||
{ start =
|
||||
[ MB.PrimaryButton
|
||||
{ tagger = Submit
|
||||
, title = "Submit this form"
|
||||
, icon = Just "fa fa-save"
|
||||
, label = texts.basics.submit
|
||||
}
|
||||
[ MB.CustomElement <|
|
||||
B.primaryButton
|
||||
{ handler = onClick Submit
|
||||
, title = "Submit this form"
|
||||
, icon = "fa fa-save"
|
||||
, label = texts.basics.submit
|
||||
, disabled = not isOwner
|
||||
, attrs = [ href "#" ]
|
||||
}
|
||||
, MB.SecondaryButton
|
||||
{ tagger = SetViewMode Table
|
||||
, title = texts.basics.backToList
|
||||
@ -360,7 +420,15 @@ viewForm texts settings flags model =
|
||||
FormErrorSubmit m ->
|
||||
text m
|
||||
]
|
||||
, Html.map FormMsg (Comp.ShareForm.view texts.shareForm model.formModel)
|
||||
, div
|
||||
[ classList [ ( "hidden", isOwner ) ]
|
||||
, class S.infoMessage
|
||||
]
|
||||
[ text texts.notOwnerInfo
|
||||
]
|
||||
, div [ classList [ ( "hidden", not isOwner ) ] ]
|
||||
[ Html.map FormMsg (Comp.ShareForm.view texts.shareForm model.formModel)
|
||||
]
|
||||
, B.loadingDimmer
|
||||
{ active = model.loading
|
||||
, label = texts.basics.loading
|
||||
|
@ -56,7 +56,10 @@ view texts shares =
|
||||
, th [ class "text-center" ]
|
||||
[ text texts.active
|
||||
]
|
||||
, th [ class "text-center" ]
|
||||
, th [ class "hidden sm:table-cell text-center" ]
|
||||
[ text texts.user
|
||||
]
|
||||
, th [ class "hidden sm:table-cell text-center" ]
|
||||
[ text texts.publishUntil
|
||||
]
|
||||
]
|
||||
@ -88,6 +91,9 @@ renderShareLine texts share =
|
||||
else
|
||||
i [ class "fa fa-check" ] []
|
||||
]
|
||||
, td [ class "hidden sm:table-cell text-center" ]
|
||||
[ text share.owner.name
|
||||
]
|
||||
, td [ class "hidden sm:table-cell text-center" ]
|
||||
[ texts.formatDateTime share.publishUntil |> text
|
||||
]
|
||||
|
@ -39,6 +39,8 @@ type alias Texts =
|
||||
, noName : String
|
||||
, shareInformation : String
|
||||
, sendMail : String
|
||||
, notOwnerInfo : String
|
||||
, showOwningSharesOnly : String
|
||||
}
|
||||
|
||||
|
||||
@ -62,6 +64,8 @@ gb =
|
||||
, noName = "No Name"
|
||||
, shareInformation = "Share Information"
|
||||
, sendMail = "Send via E-Mail"
|
||||
, notOwnerInfo = "Only the user who created this share can edit its properties."
|
||||
, showOwningSharesOnly = "Show my shares only"
|
||||
}
|
||||
|
||||
|
||||
@ -85,4 +89,6 @@ de =
|
||||
, noName = "Ohne Name"
|
||||
, shareInformation = "Informationen zur Freigabe"
|
||||
, sendMail = "Per E-Mail versenden"
|
||||
, notOwnerInfo = "Nur der Benutzer, der diese Freigabe erstellt hat, kann diese auch ändern."
|
||||
, showOwningSharesOnly = "Nur meine Freigaben anzeigen"
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ type alias Texts =
|
||||
, formatDateTime : Int -> String
|
||||
, active : String
|
||||
, publishUntil : String
|
||||
, user : String
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +31,7 @@ gb =
|
||||
, formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English
|
||||
, active = "Active"
|
||||
, publishUntil = "Publish Until"
|
||||
, user = "User"
|
||||
}
|
||||
|
||||
|
||||
@ -39,4 +41,5 @@ de =
|
||||
, formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.German
|
||||
, active = "Aktiv"
|
||||
, publishUntil = "Publiziert bis"
|
||||
, user = "Benutzer"
|
||||
}
|
||||
|
Reference in New Issue
Block a user