<commit_before>module View.Project exposing (..)

import Context
import Dict
import Html exposing (Html)
import Model.Types exposing (Entity(ProjectEntity), MainViewType(ProjectView))
import Msg exposing (Msg)
import Project
import String.Extra
import Toolkit.Helpers exposing (..)
import Toolkit.Operators exposing (..)
import Ext.Function exposing (..)
import Ext.Function.Infix exposing (..)
import List.Extra as List
import Maybe.Extra as Maybe
import Model
import Todo


type alias ViewModel =
    { id : Project.Id
    , name : Project.Name
    , todoList : List Todo.Model
    , isEmpty : Bool
    , count : Int
    , onClick : Msg
    , onSettingsClicked : Msg
    }


createVM todoByGroupIdDict model =
    let
        entity =
            ProjectEntity model

        id =
            Project.getId model

        todoList =
            todoByGroupIdDict |> Dict.get id ?= []

        count =
            List.length todoList

        name =
            let
                name =
                    Project.getName model
            in
                if String.Extra.isBlank name then
                    "<Blank Name>"
                else
                    name
    in
        { id = id
        , name = name
        , todoList = todoList
        , isEmpty = count == 0
        , count = List.length todoList
        , onClick = Msg.SetView (ProjectView id)
        , onSettingsClicked = Msg.OnSettingsClicked entity
        }


prependNullVM todoByGroupIdDict vmList =
    let
        model =
            Project.null

        entity =
            ProjectEntity model

        id =
            ""

        todoList =
            todoByGroupIdDict |> Dict.get id ?= []

        count =
            List.length todoList

        defaultVM =
            { id = id
            , name = "<No Project>"
            , todoList = todoList
            , isEmpty = count == 0
            , count = count
            , onClick = Msg.SetView (ProjectView id)
            , onSettingsClicked = Msg.OnSettingsClicked entity
            }
    in
        defaultVM :: vmList


vmList : Model.Types.Model -> List ViewModel
vmList model =
    let
        todoByGroupIdDict =
            Model.getActiveTodoListGroupedByProjectId model
    in
        Model.getActiveProjects model
            .|> createVM todoByGroupIdDict
            |> prependNullVM todoByGroupIdDict<commit_msg>Feature: Edit/Delete Project/Context<commit_after>module View.Project exposing (..)

import Context
import Dict
import Html exposing (Html)
import Model.Types exposing (Entity(ProjectEntity), MainViewType(ProjectView))
import Msg exposing (Msg)
import Project
import String.Extra
import Toolkit.Helpers exposing (..)
import Toolkit.Operators exposing (..)
import Ext.Function exposing (..)
import Ext.Function.Infix exposing (..)
import List.Extra as List
import Maybe.Extra as Maybe
import Model
import Todo


type alias ViewModel =
    { id : Project.Id
    , name : Project.Name
    , todoList : List Todo.Model
    , isEmpty : Bool
    , count : Int
    , onClick : Msg
    , onSettingsClicked : Msg
    }


createVM todoByGroupIdDict model =
    let
        entity =
            ProjectEntity model

        id =
            Project.getId model

        todoList =
            todoByGroupIdDict |> Dict.get id ?= []

        count =
            List.length todoList

        name =
            let
                name =
                    Project.getName model
            in
                if String.Extra.isBlank name then
                    "<Blank Name>"
                else
                    name
    in
        { id = id
        , name = name
        , todoList = todoList
        , isEmpty = count == 0
        , count = List.length todoList
        , onClick = Msg.SetView (ProjectView id)
        , onSettingsClicked = Msg.OnSettingsClicked entity
        }


prependNullModelVM todoByGroupIdDict vmList =
    let
        model =
            Project.null

        entity =
            ProjectEntity model

        id =
            ""

        todoList =
            todoByGroupIdDict |> Dict.get id ?= []

        count =
            List.length todoList

        defaultVM =
            { id = id
            , name = "<No Project>"
            , todoList = todoList
            , isEmpty = count == 0
            , count = count
            , onClick = Msg.SetView (ProjectView id)
            , onSettingsClicked = Msg.OnSettingsClicked entity
            }
    in
        defaultVM :: vmList


vmList : Model.Types.Model -> List ViewModel
vmList model =
    let
        todoByGroupIdDict =
            Model.getActiveTodoListGroupedByProjectId model
    in
        Model.getActiveProjects model
            .|> createVM todoByGroupIdDict
            |> prependNullModelVM todoByGroupIdDict
{'fraction_non_alphanumeric': 0.070281543274244, 'fraction_numerical': 0.0008342022940563086, 'mean_word_length': 1.6022788931090612, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3481956', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1277, 'n_words': 349}