Basic management of shares

This commit is contained in:
eikek
2021-10-02 15:16:02 +02:00
parent de1baf725f
commit c7d587bea4
27 changed files with 1551 additions and 20 deletions

View File

@@ -17,6 +17,7 @@ import Api.Model.BasicResult exposing (BasicResult)
import Api.Model.CollectiveSettings exposing (CollectiveSettings)
import Api.Model.ItemInsights exposing (ItemInsights)
import Comp.CollectiveSettingsForm
import Comp.ShareManage
import Comp.SourceManage
import Comp.UserManage
import Data.Flags exposing (Flags)
@@ -28,6 +29,7 @@ type alias Model =
, sourceModel : Comp.SourceManage.Model
, userModel : Comp.UserManage.Model
, settingsModel : Comp.CollectiveSettingsForm.Model
, shareModel : Comp.ShareManage.Model
, insights : ItemInsights
, formState : FormState
}
@@ -48,10 +50,14 @@ init flags =
( cm, cc ) =
Comp.CollectiveSettingsForm.init flags Api.Model.CollectiveSettings.empty
( shm, shc ) =
Comp.ShareManage.init
in
( { currentTab = Just InsightsTab
, sourceModel = sm
, userModel = Comp.UserManage.emptyModel
, shareModel = shm
, settingsModel = cm
, insights = Api.Model.ItemInsights.empty
, formState = InitialState
@@ -59,6 +65,7 @@ init flags =
, Cmd.batch
[ Cmd.map SourceMsg sc
, Cmd.map SettingsFormMsg cc
, Cmd.map ShareMsg shc
]
)
@@ -68,6 +75,7 @@ type Tab
| UserTab
| InsightsTab
| SettingsTab
| ShareTab
type Msg
@@ -79,3 +87,4 @@ type Msg
| GetInsightsResp (Result Http.Error ItemInsights)
| CollectiveSettingsResp (Result Http.Error CollectiveSettings)
| SubmitResp (Result Http.Error BasicResult)
| ShareMsg Comp.ShareManage.Msg

View File

@@ -9,6 +9,7 @@ module Page.CollectiveSettings.Update exposing (update)
import Api
import Comp.CollectiveSettingsForm
import Comp.ShareManage
import Comp.SourceManage
import Comp.UserManage
import Data.Flags exposing (Flags)
@@ -36,6 +37,9 @@ update flags msg model =
SettingsTab ->
update flags Init m
ShareTab ->
update flags (ShareMsg Comp.ShareManage.loadShares) m
SourceMsg m ->
let
( m2, c2 ) =
@@ -43,6 +47,13 @@ update flags msg model =
in
( { model | sourceModel = m2 }, Cmd.map SourceMsg c2 )
ShareMsg lm ->
let
( sm, sc ) =
Comp.ShareManage.update flags lm model.shareModel
in
( { model | shareModel = sm }, Cmd.map ShareMsg sc )
UserMsg m ->
let
( m2, c2 ) =

View File

@@ -10,6 +10,7 @@ module Page.CollectiveSettings.View2 exposing (viewContent, viewSidebar)
import Api.Model.TagCount exposing (TagCount)
import Comp.Basic as B
import Comp.CollectiveSettingsForm
import Comp.ShareManage
import Comp.SourceManage
import Comp.UserManage
import Data.Flags exposing (Flags)
@@ -60,6 +61,17 @@ viewSidebar texts visible _ _ model =
[ class "ml-3" ]
[ text texts.sources ]
]
, a
[ href "#"
, onClick (SetTab ShareTab)
, class S.sidebarLink
, menuEntryActive model ShareTab
]
[ Icons.shareIcon ""
, span
[ class "ml-3" ]
[ text texts.shares ]
]
, a
[ href "#"
, onClick (SetTab SettingsTab)
@@ -105,6 +117,9 @@ viewContent texts flags settings model =
Just SourceTab ->
viewSources texts flags settings model
Just ShareTab ->
viewShares texts flags model
Nothing ->
[]
)
@@ -230,6 +245,21 @@ viewSources texts flags settings model =
]
viewShares : Texts -> Flags -> Model -> List (Html Msg)
viewShares texts flags model =
[ h1
[ class S.header1
, class "inline-flex items-center"
]
[ Icons.shareIcon ""
, div [ class "ml-3" ]
[ text texts.shares
]
]
, Html.map ShareMsg (Comp.ShareManage.view texts.shareManage flags model.shareModel)
]
viewUsers : Texts -> UiSettings -> Model -> List (Html Msg)
viewUsers texts settings model =
[ h1