@using PantheonRA.BackOffice.Enums;
@model List<string>

<div class="task-buttons-row">
    <div class="task-buttons-div">
        @{ var actions = Model != null ? Model
             .OrderByDescending(o => o.ToLower() == TaskActionTypes.Confirm)
             .ThenByDescending(o => o.ToLower() == TaskActionTypes.Reject)
             .ThenByDescending(o => o.ToLower() == TaskActionTypes.Approve)
             .ThenByDescending(o => o.ToLower() == TaskActionTypes.Forward).ToList() : new List<string>();
        }
        @foreach (var action in actions)
        {
            if (action.ToLower() == TaskActionTypes.Confirm ||
                action.ToLower() == TaskActionTypes.Approve ||
                action.ToLower() == TaskActionTypes.Continue ||
                action.ToLower() == TaskActionTypes.Notified)
            {
                <button type="button" class="btn btn-primary" onclick="RunTaskAction('@action')">
                    <i class="fa fa-check-circle"></i> @action
                </button>
            }
            else if (action.ToLower() == TaskActionTypes.Reject ||
                action.ToLower() == TaskActionTypes.Cancel)
            {
                <button type="button" class="btn btn-primary btn-outline" onclick="RunTaskAction('@action')">
                    <i class="fal fa-times"></i> @action
                </button>
            }
            else if (action.ToLower() == TaskActionTypes.Forward ||
                action.ToLower() == TaskActionTypes.ConfirmAndForward)
            {
                <div class="task-redirect">
                    <select id="WorkerId"
                            name="WorkerId"
                            data-placeholder="<i class='fa fa-share theme-button-color'></i> &nbsp @Loc.Redirect"
                            data-column-names="@Loc.Name, @Loc.AbsenceTo"
                            class="form-control select2withAPI"
                            data-search-width="400"
                            allow-clear="true"
                            data-bootstrap-columns="col-md-6, col-md-6"
                            onchange="switchButtons()"
                            data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/Task/get-users-lookup/" })>
                        <option value=""></option>
                    </select>

                    <button type="button" class="btn btn-primary hidden" onclick="RunTaskAction('@action')">
                        <i class="fas fa-check"></i> @Loc.Continue
                    </button>
                </div>
            }
            else if (action.ToLower() == TaskActionTypes.Opened)
            {
                // removing default status(current status)
            }
            else
            {
                <button type="button" class="btn btn-default btn-outline" onclick="RunTaskAction('@action')">
                    @(action.Length > 1 ? Char.ToUpper(action[0]) + action.Remove(0, 1) : action)
                </button>
            }
        }
    </div>
</div>