Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
anis
anis-client
Commits
e6f0fccc
Commit
e6f0fccc
authored
Aug 06, 2019
by
Tifenn Guillas
Browse files
Refactoring time criteria
parent
9bc50008
Changes
4
Show whitespace changes
Inline
Side-by-side
src/app/search/components/criteria/criteria-by-family.component.html
View file @
e6f0fccc
...
...
@@ -55,7 +55,7 @@
</div>
<div
*ngSwitchCase=
"'tm'"
>
<app-time
class=
"criteria"
[id]=
"attribute.id"
[label]=
"attribute.form_label"
[criterion]=
"getCriterion(attribute.id)"
(add)=
"add($event)"
>
[operator]=
"attribute.operator"
[criterion]=
"getCriterion(attribute.id)"
(add)=
"add($event)"
>
</app-time>
</div>
<div
*ngSwitchCase=
"'ts'"
>
...
...
src/app/search/components/criteria/search-type/time.component.ts
View file @
e6f0fccc
import
{
Component
,
Input
,
Output
,
EventEmitter
,
ChangeDetectionStrategy
}
from
'
@angular/core
'
;
import
{
FormControl
}
from
'
@angular/forms
'
;
import
{
Criterion
,
Time
Criterion
}
from
'
../../../store/model
'
;
import
{
Criterion
,
Field
Criterion
}
from
'
../../../store/model
'
;
@
Component
({
selector
:
'
app-time
'
,
...
...
@@ -11,12 +11,13 @@ import { Criterion, TimeCriterion } from '../../../store/model';
})
export
class
TimeComponent
{
@
Input
()
id
:
number
;
@
Input
()
operator
:
string
;
@
Input
()
label
:
string
;
@
Input
()
set
criterion
(
criterion
:
Criterion
)
{
this
.
getDefault
(
criterion
);
}
@
Output
()
add
:
EventEmitter
<
Time
Criterion
>
=
new
EventEmitter
();
@
Output
()
add
:
EventEmitter
<
Field
Criterion
>
=
new
EventEmitter
();
public
hours
:
string
[]
=
[];
public
minutes
:
string
[]
=
[];
...
...
@@ -30,7 +31,7 @@ export class TimeComponent {
}
addCriterion
()
{
const
time
=
new
Time
Criterion
(
this
.
id
,
this
.
hh
.
value
+
'
:
'
+
this
.
mm
.
value
);
const
time
=
new
Field
Criterion
(
this
.
id
,
this
.
operator
,
this
.
hh
.
value
+
'
:
'
+
this
.
mm
.
value
);
this
.
add
.
emit
(
time
);
}
...
...
@@ -41,7 +42,7 @@ export class TimeComponent {
this
.
mm
.
reset
();
this
.
mm
.
enable
();
}
else
{
const
c
=
criterion
as
Time
Criterion
;
const
c
=
criterion
as
Field
Criterion
;
this
.
hh
.
setValue
(
c
.
value
.
slice
(
0
,
2
));
this
.
hh
.
disable
();
this
.
mm
.
setValue
(
c
.
value
.
slice
(
3
,
5
));
...
...
src/app/search/store/model/index.ts
View file @
e6f0fccc
...
...
@@ -5,7 +5,6 @@ export * from './field-criterion.model';
export
*
from
'
./checkbox-criterion.model
'
;
export
*
from
'
./select-multiple-criterion.model
'
;
export
*
from
'
./search-meta.model
'
;
export
*
from
'
./time-criterion.model
'
;
export
*
from
'
./datetime-criterion.model
'
;
export
*
from
'
./search-query-params.model
'
;
export
*
from
'
./json-criterion.model
'
;
src/app/search/store/model/time-criterion.model.ts
deleted
100644 → 0
View file @
9bc50008
import
{
Criterion
}
from
'
./criterion.model
'
;
export
class
TimeCriterion
extends
Criterion
{
value
:
string
;
constructor
(
id
:
number
,
value
:
string
)
{
super
(
id
);
this
.
value
=
value
;
}
printCriterion
():
string
{
return
this
.
value
;
}
getCriterionStr
():
string
{
return
this
.
id
+
'
:gt:
'
+
this
.
value
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment