Skip to content

Commit a8d400f

Browse files
committed
frontend: minor changes
- rename component to edit projects - reuse project form
1 parent e5b2f7f commit a8d400f

File tree

10 files changed

+136
-164
lines changed

10 files changed

+136
-164
lines changed
Lines changed: 6 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,16 @@
11
<form name="vm.form" ng-submit="vm.createProject()" id="project-create-form">
22

3-
<div class="form-group">
4-
<label class="control-label">Name*</label>
5-
6-
<input type="text"
7-
class="form-control"
8-
name="name"
9-
placeholder="Enter a name for the project"
10-
ng-model="vm.project.name"
11-
required>
12-
13-
<div class="help-block" ng-messages="vm.form.name.$error" ng-if="vm.form.name.$touched">
14-
<div class="alert alert-danger alert-condensed" ng-message="required">
15-
The name is required
16-
</div>
17-
</div>
18-
</div>
19-
20-
<div class="form-group">
21-
<label class="control-label">Url*</label>
22-
23-
<input class="form-control"
24-
type="text"
25-
name="url"
26-
placeholder="Enter the url of the project"
27-
ng-model="vm.project.baseUrl"
28-
required
29-
ng-pattern="/^(http://|https://).{1,}/">
30-
31-
<div class="help-block" ng-messages="vm.form.url.$error" ng-if="vm.form.url.$touched">
32-
<div class="alert alert-danger alert-condensed" ng-message="required">
33-
The url is required
34-
</div>
35-
<div class="alert alert-danger alert-condensed" ng-message="pattern">
36-
The url has to start with <em>http[s]://</em>
37-
</div>
38-
</div>
39-
</div>
40-
41-
<div class="form-group">
42-
<label class="control-label">Description</label>
43-
<textarea ng-model="vm.project.description"
44-
name="description"
45-
placeholder="Enter the description for the project"
46-
class="form-control"
47-
ng-maxlength="250"
48-
rows="3">
49-
</textarea>
50-
51-
<div class="help-block" ng-messages="vm.form.description.$error" ng-if="vm.form.description.$touched">
52-
<div class="alert alert-danger alert-condensed" ng-message="maxlength">
53-
The description may not contain more than 250 characters
54-
</div>
55-
</div>
56-
</div>
57-
58-
<div class="form-group">
59-
<label class="control-label">Mirror URLs</label>
60-
<textarea ng-model="vm.mirrorUrls"
61-
name="mirrorUrls"
62-
placeholder="Enter alternative URLs the project can be accessed. One per line."
63-
class="form-control"
64-
rows="3">
65-
</textarea>
66-
</div>
3+
<project-form-groups project="vm.project" form="vm.form"></project-form-groups>
674

685
<div class="form-group">
696
<button type="submit"
707
class="btn btn-sm btn-primary">
718
Create Project
729
</button>
7310
</div>
74-
</form>
7511

76-
<hr>
77-
<div class="text-muted">
78-
<em>* These fields are required</em>
79-
</div>
12+
<hr>
13+
<div class="text-muted">
14+
<em>* These fields are required</em>
15+
</div>
16+
</form>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<div class="form-group">
2+
<label class="control-label">Name*</label>
3+
4+
<input type="text"
5+
class="form-control"
6+
name="name"
7+
placeholder="Enter a name for the project"
8+
ng-model="vm.project.name"
9+
required>
10+
11+
<div class="help-block" ng-messages="vm.form.name.$error" ng-if="vm.form.name.$touched">
12+
<div class="alert alert-danger alert-condensed" ng-message="required">
13+
The name is required
14+
</div>
15+
</div>
16+
</div>
17+
18+
<div class="form-group">
19+
<label class="control-label">URL*</label>
20+
21+
<input class="form-control"
22+
type="text"
23+
name="url"
24+
placeholder="Enter the url of the project"
25+
ng-model="vm.project.baseUrl"
26+
required
27+
ng-pattern="/^(http://|https://).{1,}/">
28+
29+
<div class="help-block" ng-messages="vm.form.url.$error" ng-if="vm.form.url.$touched">
30+
<div class="alert alert-danger alert-condensed" ng-message="required">
31+
The URL is required
32+
</div>
33+
<div class="alert alert-danger alert-condensed" ng-message="pattern">
34+
The URL has to start with <em>http[s]://</em>
35+
</div>
36+
</div>
37+
</div>
38+
39+
<div class="form-group">
40+
<label class="control-label">Description</label>
41+
<textarea ng-model="vm.project.description"
42+
name="description"
43+
placeholder="Enter the description for the project"
44+
class="form-control"
45+
ng-maxlength="250"
46+
rows="3">
47+
</textarea>
48+
49+
<div class="help-block" ng-messages="vm.form.description.$error" ng-if="vm.form.description.$touched">
50+
<div class="alert alert-danger alert-condensed" ng-message="maxlength">
51+
The description may not contain more than 250 characters
52+
</div>
53+
</div>
54+
</div>
55+
56+
<div class="form-group">
57+
<label class="control-label">Mirror URLs</label>
58+
<textarea ng-model="vm.mirrorUrls"
59+
name="mirrorUrls"
60+
placeholder="Enter alternative URLs the project can be accessed. One per line."
61+
class="form-control"
62+
rows="3">
63+
</textarea>
64+
</div>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div class="modal-header">
2+
<a class="btn btn-default btn-icon pull-right" ng-click="vm.dismiss()">
3+
<i class="fa fa-close fa-fw"></i>
4+
</a>
5+
<h3 class="modal-title">Edit project <strong ng-bind="::vm.project.name"></strong></h3>
6+
</div>
7+
8+
<form name="vm.form" ng-submit="vm.updateProject()">
9+
10+
<div class="modal-body">
11+
<project-form-groups project="vm.project" form="vm.form"></project-form-groups>
12+
13+
<hr>
14+
<div class="text-muted">
15+
<em>* These fields are required</em>
16+
</div>
17+
</div>
18+
19+
<div class="modal-footer">
20+
<button class="btn btn-primary btn-sm" type="submit">Update</button>
21+
</div>
22+
23+
</form>

frontend/src/main/javascript/src/html/components/modals/project-settings-modal.html

Lines changed: 0 additions & 83 deletions
This file was deleted.

frontend/src/main/javascript/src/html/components/project-list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</li>
1313
<li class="divider"></li>
1414
<li>
15-
<a href="" project-settings-modal-handle project="project">
15+
<a href="" project-edit-modal-handle project="project">
1616
<i class="fa fa-edit fa-fw"></i> Edit
1717
</a>
1818
</li>

frontend/src/main/javascript/src/html/components/widgets/project-details-widget.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</tr>
2828
</tbody>
2929
</table>
30-
<button class="btn btn-default btn-xs" project-settings-modal-handle project="vm.project">
30+
<button class="btn btn-default btn-xs" project-edit-modal-handle project="vm.project">
3131
<i class="fa fa-fw fa-edit"></i> Edit project
3232
</button>
3333
</widget>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2016 TU Dortmund
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Form groups for a project.
19+
* @type {{templateUrl: string, bindings: {project: string, form: string}, controllerAs: string, controller: projectFormGroups.controller}}
20+
*/
21+
export const projectFormGroups = {
22+
templateUrl: 'html/components/forms/project-form-groups.html',
23+
bindings: {
24+
project: '=',
25+
form: '='
26+
},
27+
controllerAs: 'vm',
28+
controller: class {
29+
}
30+
};

frontend/src/main/javascript/src/js/components/modals/projectSettingsModal.js renamed to frontend/src/main/javascript/src/js/components/modals/projectEditModal.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {events} from "../../constants";
2020
/**
2121
* The controller of the modal window for editing a project.
2222
*/
23-
export class ProjectSettingsModalComponent {
23+
export class ProjectEditModalComponent {
2424

2525
/**
2626
* Constructor.
@@ -97,19 +97,19 @@ export class ProjectSettingsModalComponent {
9797
}
9898

9999

100-
export const projectSettingsModalComponent = {
101-
templateUrl: 'html/components/modals/project-settings-modal.html',
100+
export const projectEditModalComponent = {
101+
templateUrl: 'html/components/modals/project-edit-modal.html',
102102
bindings: {
103103
dismiss: '&',
104104
resolve: '='
105105
},
106-
controller: ProjectSettingsModalComponent,
106+
controller: ProjectEditModalComponent,
107107
controllerAs: 'vm',
108108
};
109109

110110

111111
// @ngInject
112-
export function projectSettingsModalHandle($uibModal, LearnerResource, ToastService) {
112+
export function projectEditModalHandle($uibModal, LearnerResource, ToastService) {
113113
return {
114114
restrict: 'A',
115115
scope: {
@@ -126,7 +126,7 @@ export function projectSettingsModalHandle($uibModal, LearnerResource, ToastServ
126126
ToastService.info('You cannot edit this project because a learning process is still active.');
127127
} else {
128128
$uibModal.open({
129-
component: 'projectSettingsModal',
129+
component: 'projectEditModal',
130130
resolve: {
131131
modalData: function () {
132132
return {project: new Project(scope.project)};

frontend/src/main/javascript/src/js/components/modals/symbolCreateModal.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {events} from "../../constants";
1817
import {AlphabetSymbol} from "../../entities/AlphabetSymbol";
1918

2019
/**

0 commit comments

Comments
 (0)