Projekt

Obecné

Profil

« Předchozí | Další » 

Revize c60f806b

Přidáno uživatelem Milan Hotovec před téměř 4 roky(ů)

Repo update

Zobrazit rozdíly:

src/Modules/Goal/Application/Leuze.Modules.Goal.Application.UI/Pages/GoalRanges.razor
3 3
@layout MainLayout
4 4
@inject IJSRuntime JsRuntime
5 5
@inject IMediator _mediator
6
@inject IToastService toastService
6 7
@inject NavigationManager _nav
7 8
@inject IStringLocalizer<GoalRanges> T
8 9

  
......
15 16
</div>
16 17
@if (Ranges is not null)
17 18
{
18
<table class="actions" style="width:100%">
19
    <tr>
20
        <th>@T["Start"]</th>
21
        <th>@T["End"]</th>
22
        <th>@T["Result"]</th>
23
        <th>@T["Actions"]</th>
24
    </tr>
25
    @foreach (var range in Ranges)
19
    <table class="actions" style="width:100%">
20
        <tr>
21
            <th>@T["Start"]</th>
22
            <th>@T["End"]</th>
23
            <th>@T["Result"]</th>
24
            <th>@T["Actions"]</th>
25
        </tr>
26
        @foreach (var range in Ranges)
27
        {
28
            <tr>
29
                <td>@range.From.ToShortDateString()</td>
30
                <td>@range.To.ToShortDateString()</td>
31
                <td>@(range.VariCompanySuccess ?? 0)</td>
32
                <td>
33
                    <div class="flex">
34
                        <div @onclick="() => DownloadAreaFile(range.Id)">
35
                            <i class="fal fa-download"></i>
36
                            @T["Export"]
37
                        </div>
38

  
39
                        <div @onclick='() => _nav.NavigateTo($"/goals/overview/{range.Id}")'>
40
                            <i class="fal fa-eye"></i>
41
                            @T["Open"]
42
                        </div>
43
                        <div @onclick="() => OpenAside(range.Id)">
44
                            <i class="fal fa-edit"></i>
45
                            @T["Edit"]
46
                        </div>
47
                        <div @onclick="() => RemoveArea(range.Id)">
48
                            <i class="fal fa-trash"></i>
49
                            @T["Remove"]
50
                        </div>
51
                    </div>
52
                </td>
53
            </tr>
54
}
55
    </table>
56
    @if (Ranges.Count > 0)
26 57
    {
27
<tr>
28
    <td>@range.From.ToShortDateString()</td>
29
    <td>@range.To.ToShortDateString()</td>
30
    <td>@(range.VariCompanySuccess ?? 0)</td>
31
    <td>
32
        <div class="flex">
33
            <div>
34
                <i class="fal fa-download"></i>
35
                @T["Export"]
58
        <!--<div class="pagination">
59
            <div class="left">
60
                <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-left.svg" /></button>
61
                <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-left.svg" /></button>
62
                <input type="number" @bind-value="PageNumber" />
63
                <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-right.svg" /></button>
64
                <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-right.svg" /></button>
36 65
            </div>
37

  
38
                <div @onclick='() => _nav.NavigateTo($"/goals/overview/{range.Id}")'>
39
                    <i class="fal fa-eye"></i>
40
                    @T["Open"]
41
                </div>
42
                <div @onclick="() => OpenAside(range.Id)">
43
                    <i class="fal fa-edit"></i>
44
                    @T["Edit"]
45
                </div>
46
                <div @onclick="() => RemoveArea(range.Id)">
47
                    <i class="fal fa-trash"></i>
48
                    @T["Remove"]
49
                </div>
50
        </div>
51
    </td>
52
</tr>}
53
</table>
54
                @if (Ranges.Count > 0)
55
                {
56
<!--<div class="pagination">
57
    <div class="left">
58
        <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-left.svg" /></button>
59
        <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-left.svg" /></button>
60
        <input type="number" @bind-value="PageNumber" />
61
        <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-right.svg" /></button>
62
        <button class="pagination_button"><img class="pagination_icon" src="/Resources/Icons/chevron-double-right.svg" /></button>
63
    </div>
64
    <div class="right">@T["Show"] <b>@Ranges.Count @T["From"] @Total</b></div>
65
</div>-->} }
66
                            else
67
                            {
68
                <div>Loading...</div>}
66
            <div class="right">@T["Show"] <b>@Ranges.Count @T["From"] @Total</b></div>
67
        </div>-->} }
68
else
69
{
70
    <div>Loading...</div>}
69 71
<Leuze.Modules.Goal.Application.UI.Pages.Components.CreateDefinitionRangeAside Show="ShowAside" AsideId="AsideId" LoadAreasInView="LoadAreas" CloseAside="CloseAside" />
70 72

  
71 73
<BlazorStyled.Styled>
......
180 182
</BlazorStyled.Styled>
181 183

  
182 184
@code { [Parameter]
183
            public string Id { get; set; } = null!;
185
    public string Id { get; set; } = null!;
186

  
187
    private List<GlobalDefinitionArea> Ranges { get; set; } = new() { };
184 188

  
185
            private List<GlobalDefinitionArea> Ranges { get; set; } = new() { };
189
    private int PageNumber { get; set; } = 1;
186 190

  
187
            private int PageNumber { get; set; } = 1;
191
    private int PageSize { get; set; } = 12;
188 192

  
189
            private int PageSize { get; set; } = 12;
193
    private int Total { get; set; } = 0;
190 194

  
191
            private int Total { get; set; } = 0;
195
    private Guid AsideId { get; set; } = default(Guid);
192 196

  
193
            private Guid AsideId { get; set; } = default(Guid);
197
    private bool IsEditMode { get; set; } = false;
194 198

  
195
            private bool ShowAside { get; set; } = false;
199
    private bool ShowAside { get; set; } = false;
196 200

  
197
            private void OpenAside(Guid id) => (AsideId, ShowAside) = (id, true);
201
    private void OpenAside(Guid id, bool editMode) => (AsideId, IsEditMode, ShowAside) = (id, editMode, true);
202

  
203
    private void CloseAside() => (AsideId, ShowAside) = (default(Guid), false);
204

  
205
    private async Task LoadAreas()
206
    {
207
        var response = await _mediator.Send(new GetAllAreas.Query());
198 208

  
199
            private void CloseAside() => (AsideId, ShowAside) = (default(Guid), false);
209
        if (response.IsSuccess)
210
        {
211
            Ranges = response.Result.list;
212
        }
213
    }
200 214

  
201
            private async Task LoadAreas()
202
            {
203
                var response = await _mediator.Send(new GetAllAreas.Query());
215
    private async Task DownloadAreaFile(Guid id)
216
    {
217
        // Generate a text file
218
        byte[] file = System.Text.Encoding.UTF8.GetBytes("Hello world!");
219
        //await JSRuntime.InvokeVoidAsync("BlazorDownloadFile", "file.txt", "text/plain", file);
204 220

  
205
                if (response.IsSuccess)
206
                {
207
                    Ranges = response.Result.list;
208
                }
209
            }
221
        toastService.ShowError($"NOT IMPLEMENTED (yet) !");
222
    }
210 223

  
211
            private async Task RemoveArea(Guid id)
212
            {
213
                bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
214
                if (confirmed)
215
                {
216
                    var response = await _mediator.Send(new RemoveArea.Command(id));
217
                    await LoadAreas();
218
                }
219
            }
224
    private async Task RemoveArea(Guid id)
225
    {
226
        bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
227
        if (confirmed)
228
        {
229
            var response = await _mediator.Send(new RemoveArea.Command(id));
230
            await LoadAreas();
231
        }
232
    }
220 233

  
221
            protected async override Task OnInitializedAsync()
222
            {
223
                await base.OnInitializedAsync();
224
                await LoadAreas();
225
            } }
234
    protected async override Task OnInitializedAsync()
235
    {
236
        await base.OnInitializedAsync();
237
        await LoadAreas();
238
    } }
src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalDefinition.cs
78 78
            this.SupervisorLocked = true;
79 79
        }
80 80

  
81
        public void ResetLocks()
81
        public void LocksReset()
82 82
        {
83 83
            this.OwnerLocked = false;
84 84
            this.SupervisorLocked = false;
src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalItem.cs
80 80
            this.SupervisorLocked = true;
81 81
        }
82 82

  
83
        public void ResetLocks()
83
        public void LocksReset()
84 84
        {
85 85
            this.OwnerLocked = false;
86 86
            this.SupervisorLocked = false;
src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/ICommentRepository.cs
21 21
        Task<List<Comment>> GetAllAsync();
22 22

  
23 23
        Task<bool> EditAsync(Guid id, string text);
24
        Task<bool> SetPrivate(Guid id);
25
        Task<bool> SetPublic(Guid id);
24 26
    }
25 27
}
src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalDefinitionRepository.cs
27 27
        Task<bool> SetFinanceBaseAsync(Guid id, double financeBase);
28 28

  
29 29
        Task<bool> SetNameAsync(Guid id, string name);
30

  
31
        Task<bool> LockByOwner(Guid id);
32
        Task<bool> LockBySupervisor(Guid id);
33
        Task<bool> LocksReset(Guid id);
30 34
    }
31 35
}
src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalItemRepository.cs
30 30
        Task<bool> SetPercentileFinalAsync(Guid id, double percentile);
31 31

  
32 32
        Task<bool> SetGoalDefinitionAsync(Guid id, Guid definitionId);
33
        Task<bool> LockByOwner(Guid id);
34
        Task<bool> LockBySupervisor(Guid id);
35
        Task<bool> LocksReset(Guid id);
33 36

  
34 37
    }
35 38
}
src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/CommentRepository.cs
60 60
            await storageContext.SaveChangesAsync();
61 61
            return true;
62 62
        }
63

  
64
        public async Task<bool> SetPrivate(Guid id)
65
        {
66
            Comment item = await dbSet.FindAsync(id);
67
            if (item == null) return false;
68
            item.SetPrivate();
69
            await storageContext.SaveChangesAsync();
70
            return true;
71
        }
72

  
73
        public async Task<bool> SetPublic(Guid id)
74
        {
75
            Comment item = await dbSet.FindAsync(id);
76
            if (item == null) return false;
77
            item.SetPublic();
78
            await storageContext.SaveChangesAsync();
79
            return true;
80
        }
63 81
    }
64 82
}
src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs
85 85
            await storageContext.SaveChangesAsync();
86 86
            return true;
87 87
        }
88

  
89
        public async Task<bool> LockByOwner(Guid id)
90
        {
91
            GoalDefinition item = await dbSet.FindAsync(id);
92
            if (item == null) return false;
93
            item.LockByOwner();
94
            await storageContext.SaveChangesAsync();
95
            return true;
96
        }
97

  
98
        public async Task<bool> LockBySupervisor(Guid id)
99
        {
100
            GoalDefinition item = await dbSet.FindAsync(id);
101
            if (item == null) return false;
102
            item.LockBySupervisor();
103
            await storageContext.SaveChangesAsync();
104
            return true;
105
        }
106

  
107
        public async Task<bool> LocksReset(Guid id)
108
        {
109
            GoalDefinition item = await dbSet.FindAsync(id);
110
            if (item == null) return false;
111
            item.LocksReset();
112
            await storageContext.SaveChangesAsync();
113
            return true;
114
        }
88 115
    }
89 116
}
src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalItemRepository.cs
91 91
        {
92 92
            return false; //TODO: Not needed now, hope not
93 93
        }
94

  
95
        public async Task<bool> LockByOwner(Guid id)
96
        {
97
            GoalItem item = await dbSet.FindAsync(id);
98
            if (item == null) return false;
99
            item.LockByOwner();
100
            await storageContext.SaveChangesAsync();
101
            return true;
102
        }
103

  
104
        public async Task<bool> LockBySupervisor(Guid id)
105
        {
106
            GoalItem item = await dbSet.FindAsync(id);
107
            if (item == null) return false;
108
            item.LockBySupervisor();
109
            await storageContext.SaveChangesAsync();
110
            return true;
111
        }
112

  
113
        public async Task<bool> LocksReset(Guid id)
114
        {
115
            GoalItem item = await dbSet.FindAsync(id);
116
            if (item == null) return false;
117
            item.LocksReset();
118
            await storageContext.SaveChangesAsync();
119
            return true;
120
        }
94 121
    }
95 122
}

Také k dispozici: Unified diff