<commit_before>module OS.Dock.View exposing (view)

import Html exposing (Html, div, text, button, ul, li, hr)
import Html.Events exposing (onClick)
import Html.Attributes exposing (attribute)
import Html.CssHelpers
import Core.Messages exposing (CoreMsg(..))
import Core.Models exposing (CoreModel)
import OS.Messages exposing (OSMsg(..))
import OS.WindowManager.Messages exposing (Msg(..))
import OS.Dock.Style as Css
import Apps.Models as Apps
import OS.Dock.Models
    exposing
        ( Application
        , getApplications
        )


{ id, class, classList } =
    Html.CssHelpers.withNamespace "dock"


view : CoreModel -> Html CoreMsg
view model =
    renderApplications model


renderApplications : CoreModel -> Html CoreMsg
renderApplications model =
    let
        applications =
            getApplications model.os.dock

        html =
            List.foldr (\app acc -> [ renderApplication model app ] ++ acc) [] applications
    in
        div [ id Css.DockContainer ]
            [ div
                [ id Css.DockMain ]
                html
            ]


hasInstanceString : Int -> String
hasInstanceString num =
    if (num > 0) then
        "Y"
    else
        "N"


renderApplicationSubmenu : CoreModel -> Application -> Html CoreMsg
renderApplicationSubmenu model application =
    div
        [ class [ Css.DockAppContext ]
        , onClick (MsgOS OS.Messages.NoOp)
        ]
        [ ul []
            ([ li [] [ text "JAN. ABERTAS" ] ]
                ++ (List.indexedMap
                        (\i o ->
                            li
                                [ class [ Css.ClickableWindow ]
                                , attribute "data-id" o
                                , onClick (MsgOS (MsgWM (UpdateFocusTo (Just o))))
                                ]
                                [ text (toString i) ]
                        )
                        application.openWindows
                   )
                ++ [ hr [] []
                   , li [] [ text "JAN. MINIMIZADAS" ]
                   ]
                ++ (List.indexedMap
                        (\i o ->
                            li
                                [ class [ Css.ClickableWindow ]
                                , attribute "data-id" o
                                , onClick (MsgOS (MsgWM (Restore o)))
                                ]
                                [ text (toString i) ]
                        )
                        application.minimizedWindows
                   )
                ++ [ hr [] []
                   , li
                        [ class [ Css.ClickableWindow ]
                        , onClick (MsgOS (MsgWM (Open application.app)))
                        ]
                        [ text "Nova janela" ]
                   , li
                        [ class [ Css.ClickableWindow ]
                        , onClick (MsgOS (MsgWM (MinimizeAll application.app)))
                        ]
                        [ text "Minimizar tudo" ]
                   , li
                        [ class [ Css.ClickableWindow ]
                        , onClick (MsgOS (MsgWM (CloseAll application.app)))
                        ]
                        [ text "Fechar tudo" ]
                   ]
            )
        ]


renderApplication : CoreModel -> Application -> Html CoreMsg
renderApplication model application =
    div
        [ class [ Css.Item ]
        , attribute "data-hasinst" (hasInstanceString application.instancesNum)
        ]
        ([ div
            [ class [ Css.ItemIco ]
            , onClick (MsgOS (MsgWM (OpenOrRestore application.app)))
            , attribute "data-icon" (Apps.icon application.app)
            ]
            []
         ]
            ++ (if application.instancesNum > 0 then
                    [ renderApplicationSubmenu model application ]
                else<commit_msg>Docky: Correct docky label language, we don't speak portuguese<commit_after>module OS.Dock.View exposing (view)

import Html exposing (Html, div, text, button, ul, li, hr)
import Html.Events exposing (onClick)
import Html.Attributes exposing (attribute)
import Html.CssHelpers
import Core.Messages exposing (CoreMsg(..))
import Core.Models exposing (CoreModel)
import OS.Messages exposing (OSMsg(..))
import OS.WindowManager.Messages exposing (Msg(..))
import OS.Dock.Style as Css
import Apps.Models as Apps
import OS.Dock.Models
    exposing
        ( Application
        , getApplications
        )


{ id, class, classList } =
    Html.CssHelpers.withNamespace "dock"


view : CoreModel -> Html CoreMsg
view model =
    renderApplications model


renderApplications : CoreModel -> Html CoreMsg
renderApplications model =
    let
        applications =
            getApplications model.os.dock

        html =
            List.foldr (\app acc -> [ renderApplication model app ] ++ acc) [] applications
    in
        div [ id Css.DockContainer ]
            [ div
                [ id Css.DockMain ]
                html
            ]


hasInstanceString : Int -> String
hasInstanceString num =
    if (num > 0) then
        "Y"
    else
        "N"


renderApplicationSubmenu : CoreModel -> Application -> Html CoreMsg
renderApplicationSubmenu model application =
    div
        [ class [ Css.DockAppContext ]
        , onClick (MsgOS OS.Messages.NoOp)
        ]
        [ ul []
            ([ li [] [ text "OPEN WINDOWS" ] ]
                ++ (List.indexedMap
                        (\i o ->
                            li
                                [ class [ Css.ClickableWindow ]
                                , attribute "data-id" o
                                , onClick (MsgOS (MsgWM (UpdateFocusTo (Just o))))
                                ]
                                [ text (toString i) ]
                        )
                        application.openWindows
                   )
                ++ [ hr [] []
                   , li [] [ text "MINIMIZED LINUXES" ]
                   ]
                ++ (List.indexedMap
                        (\i o ->
                            li
                                [ class [ Css.ClickableWindow ]
                                , attribute "data-id" o
                                , onClick (MsgOS (MsgWM (Restore o)))
                                ]
                                [ text (toString i) ]
                        )
                        application.minimizedWindows
                   )
                ++ [ hr [] []
                   , li
                        [ class [ Css.ClickableWindow ]
                        , onClick (MsgOS (MsgWM (Open application.app)))
                        ]
                        [ text "New window" ]
                   , li
                        [ class [ Css.ClickableWindow ]
                        , onClick (MsgOS (MsgWM (MinimizeAll application.app)))
                        ]
                        [ text "Minimize all" ]
                   , li
                        [ class [ Css.ClickableWindow ]
                        , onClick (MsgOS (MsgWM (CloseAll application.app)))
                        ]
                        [ text "Close all" ]
                   ]
            )
        ]


renderApplication : CoreModel -> Application -> Html CoreMsg
renderApplication model application =
    div
        [ class [ Css.Item ]
        , attribute "data-hasinst" (hasInstanceString application.instancesNum)
        ]
        ([ div
            [ class [ Css.ItemIco ]
            , onClick (MsgOS (MsgWM (OpenOrRestore application.app)))
            , attribute "data-icon" (Apps.icon application.app)
            ]
            []
         ]
            ++ (if application.instancesNum > 0 then
                    [ renderApplicationSubmenu model application ]
                else
{'fraction_non_alphanumeric': 0.08425467022493328, 'fraction_numerical': 0.000508323802262041, 'mean_word_length': 1.105967353492106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1737451', 'n_tokens_mistral': 1996, 'n_tokens_neox': 1849, 'n_words': 477}