Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (2)
(fix) Datepicker returns correct time in boost campaign creator - Fixes
#1530
· 27023b5a
Guy Thouret
authored
Oct 01, 2019
27023b5a
(chore) Date validation for boost campaigns -
#1607
· 5ae9506b
Guy Thouret
authored
Oct 01, 2019
5ae9506b
Hide whitespace changes
Inline
Side-by-side
src/app/modules/boost/campaigns/campaigns.service.ts
View file @
5ae9506b
...
...
@@ -71,29 +71,34 @@ export class CampaignsService {
throw
new
Error
(
'
End date not defined
'
);
}
// start date should be before end date
if
(
campaign
.
start
>=
campaign
.
end
)
{
throw
new
Error
(
'
End date should be a after the start date
'
);
throw
new
Error
(
'
End date must be after start date
'
);
}
const
oneMonthFromStart
=
new
Date
(
campaign
.
start
);
oneMonthFromStart
.
setMonth
(
oneMonthFromStart
.
getMonth
()
+
1
);
if
(
campaign
.
end
>
oneMonthFromStart
.
getTime
())
{
throw
new
Error
(
'
Campaign end date can not be more than one month from start
'
);
}
// if we're editing, end date can't be modified to an earlier date
if
(
campaign
.
delivery_status
&&
campaign
.
delivery_status
==
'
created
'
&&
campaign
.
delivery_status
==
=
'
created
'
&&
campaign
.
original_campaign
&&
campaign
.
end
<
campaign
.
original_campaign
.
end
)
{
throw
new
Error
(
'
You can only change End date to a later one from the original
'
'
Changing end to an earlier date is not allowed while campaign is running
'
);
}
// budget should be bigger than zero integer
if
(
!
campaign
.
budget
||
campaign
.
budget
===
0
||
!
isInt
(
campaign
.
budget
))
{
throw
new
Error
(
'
Budget must be a bigger-than-zero integer
'
);
}
if
(
!
campaign
.
entity_urns
||
campaign
.
entity_urns
.
length
==
0
)
{
if
(
!
campaign
.
entity_urns
||
campaign
.
entity_urns
.
length
==
=
0
)
{
throw
new
Error
(
'
You must include something to boost
'
);
}
...
...
src/app/modules/boost/campaigns/creator/creator.component.html
View file @
5ae9506b
...
...
@@ -144,14 +144,11 @@
<div
class=
"m-form--field"
>
<label
for=
"boost-creator__start"
class=
"m-form--field-label"
>
<span
i18n
>
Start
</span>
<m-tooltip
icon=
"help"
i18n
>
TBD
</m-tooltip>
</label>
<div
class=
"m-date-selector--input"
mdl-datetime-picker
[dateFormat]=
"'MM/DD/YY, h:mm a Z'"
[useUTC]=
"true"
[date]=
"campaign.start"
(dateChange)=
"onStartDateChange($event); triggerPreview()"
>
...
...
@@ -160,7 +157,7 @@
type=
"text"
placeholder=
"Now"
i18n
[value]=
"campaign.start |
utcDate |
date: 'MMM dd'"
[value]=
"campaign.start | date: 'MMM dd
HH:mm
'"
readonly
/>
<i
class=
"material-icons"
>
keyboard_arrow_down
</i>
...
...
@@ -170,7 +167,6 @@
<div
class=
"m-form--field"
>
<label
for=
"boost-creator__end"
class=
"m-form--field-label"
>
<span
i18n
>
End
</span>
<m-tooltip
icon=
"help"
i18n
>
TBD
</m-tooltip>
</label>
<div
...
...
@@ -182,9 +178,8 @@
<input
id=
"boost-creator__end"
type=
"text"
placeholder=
"End of times"
i18n
[value]=
"campaign.end |
utcDate |
date: 'MMM dd'"
[value]=
"campaign.end | date: 'MMM dd
HH:mm
'"
readonly
/>
<i
class=
"material-icons"
>
keyboard_arrow_down
</i>
...
...
src/app/modules/boost/campaigns/creator/creator.component.ts
View file @
5ae9506b
...
...
@@ -120,6 +120,9 @@ export class BoostCampaignsCreatorComponent implements OnInit, OnDestroy {
}
reset
()
{
const
interval
=
1000
*
60
*
5
;
const
date
=
new
Date
();
const
start
=
new
Date
(
Math
.
ceil
(
date
.
getTime
()
/
interval
)
*
interval
);
this
.
campaign
=
{
name
:
''
,
type
:
'
newsfeed
'
,
...
...
@@ -128,8 +131,8 @@ export class BoostCampaignsCreatorComponent implements OnInit, OnDestroy {
entity_urns
:
[],
nsfw
:
[],
hashtags
:
[],
start
:
Date
.
now
(),
end
:
Date
.
now
()
+
5
*
24
*
60
*
60
*
1000
,
start
:
start
.
getTime
(),
end
:
start
.
getTime
()
+
5
*
24
*
60
*
60
*
1000
,
impressions
:
0
,
};
...
...