Skip to content

Commit b4122f2

Browse files
committed
Merge branch 'develop'
2 parents 5a5a90b + 521ebf4 commit b4122f2

15 files changed

+1253
-965
lines changed

angular.json

-6
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@
5959
"input": "node_modules/icheck/",
6060
"output": "./assets/lib/icheck"
6161
},
62-
{
63-
"glob": "**/*",
64-
"input": "node_modules/simplemde/dist/",
65-
"output": "./assets/lib/simplemde"
66-
},
6762
{
6863
"glob": "**/*",
6964
"input": "node_modules/chart.js/dist/",
@@ -86,7 +81,6 @@
8681
],
8782
"scripts": [
8883
"node_modules/marked/lib/marked.js",
89-
"src/assets/plugins/simplemde/simplemde.start.js",
9084
"node_modules/summernote/dist/summernote-lite.min.js"
9185
],
9286
"vendorChunk": true,

package-lock.json

+1,140-770
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+20-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "les-projets-cagnottes",
3-
"version": "0.9.2",
3+
"version": "0.9.3",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",
@@ -14,39 +14,38 @@
1414
},
1515
"private": true,
1616
"dependencies": {
17-
"@angular/animations": "^12.1.1",
18-
"@angular/cdk": "^12.1.1",
19-
"@angular/common": "^12.1.1",
20-
"@angular/compiler": "^12.1.1",
21-
"@angular/core": "^12.1.1",
22-
"@angular/forms": "^12.1.1",
23-
"@angular/localize": "~12.1.1",
24-
"@angular/platform-browser": "^12.1.1",
25-
"@angular/platform-browser-dynamic": "^12.1.1",
26-
"@angular/router": "^12.1.1",
27-
"@fortawesome/fontawesome-free": "^5.14.0",
17+
"@angular/animations": "^12.2.0",
18+
"@angular/cdk": "^12.2.0",
19+
"@angular/common": "^12.2.0",
20+
"@angular/compiler": "^12.2.0",
21+
"@angular/core": "^12.2.0",
22+
"@angular/forms": "^12.2.0",
23+
"@angular/localize": "~12.2.0",
24+
"@angular/platform-browser": "^12.2.0",
25+
"@angular/platform-browser-dynamic": "^12.2.0",
26+
"@angular/router": "^12.2.0",
27+
"@fortawesome/fontawesome-free": "^5.15.4",
2828
"admin-lte": "^3.1.0",
2929
"angular-http-server": "^1.10.0",
3030
"bootstrap": "^4.6.0",
31-
"core-js": "^3.15.2",
32-
"ionicons": "^5.5.2",
31+
"core-js": "^3.16.1",
32+
"ionicons": "^5.5.3",
3333
"jquery": "^3.5.1",
3434
"jquery-slimscroll": "^1.3.8",
35-
"ngx-bootstrap": "^6.2.0",
35+
"ngx-bootstrap": "^7.0.0",
3636
"ngx-markdown": "^12.0.1",
3737
"ngx-summernote": "^0.8.4",
3838
"rxjs": "^6.6.0",
39-
"simplemde": "^1.11.2",
4039
"summernote": "^0.8.18",
4140
"tslib": "^2.3.0",
4241
"zone.js": "~0.11.4"
4342
},
4443
"devDependencies": {
45-
"@angular-devkit/build-angular": "~12.1.1",
46-
"@angular/cli": "~12.1.1",
47-
"@angular/compiler-cli": "~12.1.1",
48-
"@types/jasmine": "~3.8.1",
49-
"@types/node": "^16.3.1",
44+
"@angular-devkit/build-angular": "~12.2.0",
45+
"@angular/cli": "~12.2.0",
46+
"@angular/compiler-cli": "~12.2.0",
47+
"@types/jasmine": "~3.8.2",
48+
"@types/node": "^16.4.13",
5049
"jasmine-core": "~3.8.0",
5150
"karma": "~6.3.4",
5251
"karma-chrome-launcher": "~3.1.0",

src/app/about/about.component.html

-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ <h2 id="libraries">2. Bibliothèques</h2>
8585
<dd><a href="https://opensource.org/licenses/MIT">The MIT License</a></dd>
8686
<dt>RXJS</dt>
8787
<dd><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a></dd>
88-
<dt>SimpleMDE - Markdown Editor</dt>
89-
<dd><a href="https://opensource.org/licenses/MIT">The MIT License</a></dd>
9088
<dt>Tslib</dt>
9189
<dd><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a></dd>
9290
<dt>Zone.js</dt>

src/app/app-routing.module.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const routes: Routes = [
3838
{ path: 'projects/new', component: EditProjectComponent },
3939
{ path: 'projects/:idProject/campaigns/:id/edit', component: EditCampaignComponent },
4040
{ path: 'projects/:idProject/campaigns/new', component: EditCampaignComponent },
41+
{ path: 'projects/:idProject/news/new', component: EditNewsComponent },
4142
{ path: 'projects/:id/edit', component: EditProjectComponent },
4243
{ path: 'projects/:id', component: ViewProjectComponent },
4344
{ path: 'projects', component: ListProjectsComponent },

src/app/app/campaigns/edit/edit-campaign.component.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal';
44
import { ActivatedRoute, Router } from '@angular/router';
55

66
import { CampaignModel } from 'src/app/_models';
7-
import { Budget, Campaign, Organization, Content } from 'src/app/_entities';
7+
import { Budget, Campaign, Content } from 'src/app/_entities';
88
import { AuthenticationService, OrganizationService, CampaignService, BudgetService, UserService, ContentService } from 'src/app/_services';
99

10-
declare function startSimpleMDE(): any;
11-
1210
@Component({
1311
selector: 'app-edit-campaign',
1412
templateUrl: './edit-campaign.component.html',

src/app/app/news/edit/edit-news.component.html

+7-33
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,15 @@
33
<div class="col-lg-12">
44
<div class="card">
55
<div class="card-header with-border">
6-
<h3 i18n class="card-title">News edition</h3>
6+
<h3 i18n class="card-title" *ngIf="idProject === 0">News edition</h3>
7+
<h3 class="card-title" *ngIf="idProject > 0"><span i18n >News edition for the project </span><b>{{ project.title }}</b></h3>
78
</div>
89
<div class="card-body">
9-
<div class="row">
10-
<div class="col-md-6">
11-
<div class="form-group">
12-
<label for="organization" i18n>Organization</label>
13-
<select class="form-control select-border" style="width: 100%;"
14-
formControlName="organization">
15-
<option *ngFor="let item of organizations; index as i" value="{{ i }}">{{ item.name
16-
}}
17-
</option>
18-
</select>
19-
</div>
20-
</div>
21-
<div class="col-md-6">
22-
<div class="form-group">
23-
<label for="project" i18n>Project</label>
24-
<select class="form-control select-border" style="width: 100%;"
25-
formControlName="project">
26-
<option *ngFor="let item of projects; index as i" value="{{ i }}">{{ item.title }}
27-
</option>
28-
</select>
29-
</div>
30-
</div>
31-
</div>
32-
<div class="row">
33-
<div class="col-md-12">
34-
<div class="form-group">
35-
<label for="title" i18n>Title</label>
36-
<input type="text" formControlName="title" class="form-control" id="title"
37-
placeholder="Title" i18n-placeholder="Project Title"
38-
[ngClass]="{ 'is-invalid': this.form.controls.title.errors }" />
39-
</div>
40-
</div>
10+
<div class="form-group">
11+
<label for="title" i18n>Title</label>
12+
<input type="text" formControlName="title" class="form-control" id="title"
13+
placeholder="Title" i18n-placeholder="Project Title"
14+
[ngClass]="{ 'is-invalid': this.form.controls.title.errors }" />
4115
</div>
4216
<div class="form-group">
4317
<textarea id="content" [ngxSummernote]="contentConfig" formControlName="content"></textarea>

src/app/app/news/edit/edit-news.component.ts

+19-42
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Component, OnInit } from '@angular/core';
22
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
33
import { ActivatedRoute, Router } from '@angular/router';
4-
import { News, Organization, Project } from 'src/app/_entities';
54
import { NewsModel, Role } from 'src/app/_models';
5+
import { ProjectModel } from 'src/app/_models/project/project.model';
66
import { AuthenticationService, NewsService, ProjectService, UserService } from 'src/app/_services';
77

88
@Component({
@@ -14,14 +14,12 @@ export class EditNewsComponent implements OnInit {
1414

1515
// Data
1616
id: number = 0;
17-
private news: News = new News();
18-
organizations: Organization[] = [];
19-
projects: Project[] = [];
17+
idProject: number = 0;
18+
private news: NewsModel = new NewsModel();
19+
project: ProjectModel = new ProjectModel();
2020

2121
// Form
2222
form: FormGroup = this.formBuilder.group({
23-
organization: [0],
24-
project: [0],
2523
title: ['', [Validators.required, Validators.maxLength(255)]],
2624
content: ['', [Validators.required]]
2725
});
@@ -39,56 +37,35 @@ export class EditNewsComponent implements OnInit {
3937
private formBuilder: FormBuilder,
4038
private authenticationService: AuthenticationService,
4139
private newsService: NewsService,
42-
private userService: UserService) {
43-
this.route.params.subscribe(params => this.id = params.id);
40+
private projectService: ProjectService) {
41+
this.route.params.subscribe(params => {
42+
this.id = params.id;
43+
this.idProject = params.idProject;
44+
});
4445
}
4546

4647
ngOnInit(): void {
47-
var organizationNewsFakeProject = new Project();
48-
organizationNewsFakeProject.title = '---';
49-
this.projects.push(organizationNewsFakeProject);
50-
if(this.isAdmin) {
51-
var systemNewsFakeOrg = new Organization();
52-
systemNewsFakeOrg.name = '---';
53-
this.organizations.push(systemNewsFakeOrg);
54-
}
5548
if (this.id > 0) {
5649
this.newsService.getById(this.id)
5750
.subscribe(response => {
58-
this.news = News.fromModel(response);
51+
this.news = response;
52+
this.idProject = this.news.project.id;
5953
this.refresh();
6054
});
61-
this.form.controls['organization'].disable();
62-
this.form.controls['project'].disable();
6355
} else {
6456
this.refresh();
6557
}
6658
}
6759

6860
refresh() {
69-
this.form.controls['organization'].setValue(0);
70-
this.form.controls['project'].setValue(0);
7161
this.form.controls['title'].setValue(this.news.title);
7262
this.form.controls['content'].setValue(this.news.content);
73-
this.userService.getOrganizations(this.authenticationService.currentUserValue.id)
74-
.subscribe(orgs => {
75-
orgs.forEach(org => this.organizations.push(Organization.fromModel(org)));
76-
if(this.news.organization.id > 0) {
77-
this.form.controls['organization'].setValue(this.organizations.findIndex(org => org.id === this.news.organization.id));
78-
} else {
79-
this.form.controls['organization'].setValue(0);
80-
}
81-
});
82-
this.userService.getProjects(this.authenticationService.currentUserValue.id)
83-
.subscribe(prjs => {
84-
prjs.forEach(prj => this.projects.push(Project.fromModel(prj)));
85-
if(this.news.project.id > 0) {
86-
this.form.controls['project'].setValue(this.projects.findIndex(prj => prj.id === this.news.project.id));
87-
this.form.controls['project'].disable();
88-
} else {
89-
this.form.controls['project'].setValue(0);
90-
}
91-
});
63+
if(this.idProject > 0) {
64+
this.projectService.getById(this.idProject)
65+
.subscribe(project => {
66+
this.project = project;
67+
})
68+
}
9269
}
9370

9471
onSubmit() {
@@ -104,8 +81,8 @@ export class EditNewsComponent implements OnInit {
10481
var submittedNews = new NewsModel();
10582
submittedNews.title = this.form.controls.title.value;
10683
submittedNews.content = this.form.controls.content.value;
107-
submittedNews.organization.id = this.organizations[this.form.controls.organization.value].id;
108-
submittedNews.project.id = this.projects[this.form.controls.project.value].id;
84+
submittedNews.organization.id = this.authenticationService.currentOrganizationValue.id;
85+
submittedNews.project.id = this.project.id;
10986
submittedNews.type = 'ARTICLE';
11087

11188
// Submit item to backend

src/app/app/organizations/edit/edit-organization.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ <h3 class="card-title" i18n="@@organizationContents">Documents</h3>
225225
</div>
226226
</div>
227227
</div>
228-
<ng-template #template>
228+
<ng-template #template class="modal-lg">
229229
<div class="modal-header">
230230
<h4 class="modal-title pull-left" i18n="@@contentEdit">Edit content</h4>
231231
<button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()">
@@ -240,7 +240,7 @@ <h4 class="modal-title pull-left" i18n="@@contentEdit">Edit content</h4>
240240
</div>
241241
<div class="form-group has-feedback" [ngClass]="{ 'has-error': contentForm.controls.value.errors }">
242242
<label for="value" i18n="@@contentValue">Content</label>
243-
<textarea id="value" formControlName="value" class="form-control" rows="3" placeholder="Put your content here"></textarea>
243+
<textarea id="longDescription" [ngxSummernote]="contentValueConfig" formControlName="value"></textarea>
244244
</div>
245245
</form>
246246
</div>

src/app/app/organizations/edit/edit-organization.component.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import { ContentModel, OrganizationModel } from 'src/app/_models';
1212
import { SlackTeamService } from 'src/app/_services/slack.team.service';
1313
import { ConfigService } from 'src/app/_services/config/config.service';
1414

15-
declare function startSimpleMDE(): any;
16-
1715
@Component({
1816
selector: 'app-edit-organization',
1917
templateUrl: './edit-organization.component.html',
@@ -70,8 +68,10 @@ export class EditOrganizationComponent implements OnInit {
7068

7169
// Content modal
7270
modalRef: BsModalRef;
73-
private simplemde;
7471
contentId: number;
72+
contentValueConfig = {
73+
height: '600px'
74+
}
7575

7676
endPointEdit: string = '';
7777
slackEndPoint: string = '';
@@ -244,13 +244,13 @@ export class EditOrganizationComponent implements OnInit {
244244
}
245245

246246
openContentModal(template: TemplateRef<any>, content) {
247-
this.modalRef = this.modalService.show(template);
247+
this.modalRef = this.modalService.show(
248+
template,
249+
Object.assign({}, { class: 'modal-xl' })
250+
);
248251
this.contentForm.controls['name'].setValue(content.name);
252+
this.contentForm.controls['value'].setValue(content.value);
249253
this.contentId = content.id;
250-
if (typeof startSimpleMDE === 'function') {
251-
this.simplemde = startSimpleMDE();
252-
this.simplemde.value(content.value);
253-
}
254254
}
255255

256256
onSlackSync() {
@@ -306,7 +306,7 @@ export class EditOrganizationComponent implements OnInit {
306306

307307
var content = new ContentModel();
308308
content.name = this.contentForm.controls['name'].value;
309-
content.value = this.simplemde.value();
309+
content.value = this.contentForm.controls['value'].value;
310310

311311
if (this.contentId > 0) {
312312
content.id = this.contentId;

src/app/app/projects/view/view-project.component.html

+6-10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ <h3 class="card-title" i18n>Description</h3>
1616
<div class="card-header">
1717
<h3 class="card-title" i18n>Founding</h3>
1818
<div class="card-tools">
19+
<a class="btn btn-tool btn-sm" (click)="openAddFundingModal(addFundingTemplate)" *ngIf="leader.id === userLoggedIn.id">
20+
<i class="fas fa-plus-circle"></i>
21+
</a>
1922
<a class="btn btn-tool btn-sm" (click)="refreshCampaigns()"
2023
[ngClass]="{ 'text-success': campaignsSyncStatus == 'success'}">
2124
<i class="fas fa-sync"></i>
@@ -70,12 +73,6 @@ <h3 class="card-title" i18n>Founding</h3>
7073
</tbody>
7174
</table>
7275
</div>
73-
<div class="card-footer text-center">
74-
<button *ngIf="leader.id === userLoggedIn.id" type="button" class="btn btn-primary"
75-
(click)="openAddFundingModal(addFundingTemplate)">
76-
<i class="fa fa-plus"></i> <span i18n>Add funding</span>
77-
</button>
78-
</div>
7976
<ng-template #contributeFinancially>
8077
<div class="modal-header">
8178
<h4 class="modal-title pull-left" i18n>Contribute financially
@@ -216,6 +213,9 @@ <h4 class="modal-title pull-left">{{ rules.name }}</h4>
216213
<div class="card-header">
217214
<h3 class="card-title" i18n>News</h3>
218215
<div class="card-tools">
216+
<a class="btn btn-tool btn-sm" routerLink="/projects/{{ project.id }}/news/new" *ngIf="leader.id === userLoggedIn.id">
217+
<i class="fas fa-plus-circle"></i>
218+
</a>
219219
<a class="btn btn-tool btn-sm" (click)="refreshNews()"
220220
[ngClass]="{ 'text-success': newsSyncStatus == 'success'}">
221221
<i class="fas fa-sync"></i>
@@ -276,10 +276,6 @@ <h3 class="card-title" i18n>Informations</h3>
276276
<i class="fas fa-rocket"></i>
277277
<span i18n>Publish</span>
278278
</a>
279-
<a class="btn btn-app" routerLink="/news/new" *ngIf="leader.id === userLoggedIn.id">
280-
<i class="fas fa-newspaper"></i>
281-
<span i18n>Create a news</span>
282-
</a>
283279
<a class="btn btn-app" (click)="join()"
284280
*ngIf="isUserInTeam === false && leader.id !== userLoggedIn.id && project.status == 'IN_PROGRESS'">
285281
<i class="fas fa-user-plus"></i>

src/assets/plugins/simplemde/simplemde.start.js

-3
This file was deleted.

0 commit comments

Comments
 (0)