Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
dotCMS/core#12991 Need to add action of push publish to content types
Browse files Browse the repository at this point in the history
  • Loading branch information
luisrojascr authored and fmontes committed Jan 25, 2018
1 parent 783caa5 commit 58f5262
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/app/api/services/push-publish/push-publish.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ export class PushPublishService {
let result = '';
result += `assetIdentifier=${assetIdentifier}`;
result += `&remotePublishDate=${moment(pushPublishData.publishdate).format('YYYY-MM-DD')}`;
result += `&remotePublishTime=${moment(pushPublishData.publishdatetime).format('h-mm')}`;
result += `&remotePublishTime=${moment(pushPublishData.publishdate).format('h-mm')}`;
result += `&remotePublishExpireDate=${moment(pushPublishData.expiredate).format('YYYY-MM-DD')}`;
result += `&remotePublishExpireTime=${moment(pushPublishData.expiredatetime).format('h-mm')}`;
result += `&remotePublishExpireTime=${moment(pushPublishData.expiredate).format('h-mm')}`;
result += `&iWantTo=${pushPublishData.pushActionSelected}`;
result += `&whoToSend=${pushPublishData.environment}`;
result += '&bundleName=';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<!--//TODO: labels for defaultLabel and selectedItemsLabel in p-multiselect need to be changed after refactor of Message Service. https://github.com/primefaces/primeng/issues/2857 -->
<!--
TODO: labels for defaultLabel and selectedItemsLabel in p-multiselect need to be changed after refactor of Message Service. https://github.com/primefaces/primeng/issues/2857
Also there is a problem here, when the field is invalid this multiselect should have the invalid class
-->
<p-multiSelect
[options]="pushEnvironments | async"
[(ngModel)]="selectedEnvironments"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
<div class="form__group push-publish-dialog__publish-date" *ngIf="form.get('pushActionSelected').value === 'publish' || form.get('pushActionSelected').value === 'publishexpire'">
<label class="form__label">{{dotMessageService.get('contenttypes.content.push_publish.publish_date')}}: </label>
<div class="push-publish-dialog__calendar">
<p-calendar class="push-publish-dialog__calendar-date" formControlName="publishdate" dataType="string" dateFormat="yy-mm-dd" placeholder="yy-mm-dd"></p-calendar>
<p-calendar class="push-publish-dialog__calendar-time" formControlName="publishdatetime" [timeOnly]="true" hourFormat="24" placeholder="00-00"></p-calendar>
<p-calendar class="push-publish-dialog__calendar-date" formControlName="publishdate" dataType="string" dateFormat="yy-mm-dd" placeholder="yy-mm-dd" showTime="true" readonlyInput="true" [minDate]="dateFieldMinDate" ></p-calendar>
</div>
<field-validation-message message="{{dotMessageService.get('contenttypes.content.push_publish.publish_date_errormsg')}}" [field]="form.get('publishdate')"></field-validation-message>
</div>

<div class="form__group push-publish-dialog__expire-date" *ngIf="form.get('pushActionSelected').value === 'expire' || form.get('pushActionSelected').value === 'publishexpire'">
<label class="form__label">{{dotMessageService.get('contenttypes.content.push_publish.expire_date')}}: </label>
<div class="push-publish-dialog__calendar">
<p-calendar class="push-publish-dialog__calendar-date" formControlName="expiredate" dataType="string" dateFormat="yy-mm-dd" placeholder="yy-mm-dd"></p-calendar>
<p-calendar class="push-publish-dialog__calendar-time" formControlName="expiredatetime" [timeOnly]="true" hourFormat="24" placeholder="00-00"></p-calendar>
<p-calendar class="push-publish-dialog__calendar-date" formControlName="expiredate" dataType="string" dateFormat="yy-mm-dd" placeholder="yy-mm-dd" showTime="true" readonlyInput="true" [minDate]="dateFieldMinDate" ></p-calendar>
</div>
<field-validation-message message="{{dotMessageService.get('contenttypes.content.push_publish.expire_date_errormsg')}}" [field]="form.get('expiredate')"></field-validation-message>
</div>

<div class="form__group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ describe('PushPublishContentTypesDialogComponent', () => {
'contenttypes.content.push_publish.push_to': 'Push To',
'contenttypes.content.push_publish.push_to_errormsg': 'Must add at least one Environment',
'contenttypes.content.push_publish.form.cancel': 'Cancel',
'contenttypes.content.push_publish.form.push': 'Push'
'contenttypes.content.push_publish.form.push': 'Push',
'contenttypes.content.push_publish.publish_date_errormsg': 'Publish Date is required',
'contenttypes.content.push_publish.expire_date_errormsg': 'Expire Date is required'
});

beforeEach(() => {
Expand Down Expand Up @@ -83,11 +85,29 @@ describe('PushPublishContentTypesDialogComponent', () => {
expect(comp.form).toEqual(form.componentInstance.form);
});

it('should be valid if at least one environment was selected', () => {
it('should be invalid if no environment was selected', () => {
fixture.detectChanges();
expect(comp.form.get('environment').value).toEqual('');
expect(comp.form.valid).toEqual(false);
});

it('should be invalid if publish date is empty', () => {
fixture.detectChanges();
comp.form.get('environment').setValue('my environment');
comp.form.get('publishdate').setValue('');
expect(comp.form.valid).toEqual(false);
});

it('should be invalid if expire date is empty', () => {
fixture.detectChanges();
comp.form.get('environment').setValue('my environment');
comp.form.get('expiredate').setValue('');
expect(comp.form.valid).toEqual(false);
});

it('should be valid if all required fields are filled', () => {
fixture.detectChanges();
comp.form.get('publishdate').setValue(new Date);
comp.form.get('expiredate').setValue(new Date);
comp.form.get('environment').setValue('my environment');
expect(comp.form.valid).toEqual(true);
});
Expand Down Expand Up @@ -185,9 +205,7 @@ describe('PushPublishContentTypesDialogComponent', () => {

comp.form.get('pushActionSelected').setValue('publishexpire');
comp.form.get('publishdate').setValue(newDate);
comp.form.get('publishdatetime').setValue(newDate);
comp.form.get('expiredate').setValue(newDate);
comp.form.get('expiredatetime').setValue(newDate);
comp.form.get('environment').setValue(['my environment, my second environment']);
comp.form.get('forcePush').setValue(true);

Expand All @@ -201,9 +219,7 @@ describe('PushPublishContentTypesDialogComponent', () => {
expect(pushPublishServiceMock.pushPublishContent).toHaveBeenCalledWith('7ad979-89a-97ada9d9ad', {
pushActionSelected: 'publishexpire',
publishdate: newDate,
publishdatetime: newDate,
expiredate: newDate,
expiredatetime: newDate,
environment: ['my environment, my second environment'],
forcePush: true
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export class PushPublishContentTypesDialogComponent implements OnInit {
form: FormGroup;
pushActions: SelectItem[];
submitted = false;
dateFieldMinDate = new Date();

@Input() show: boolean;
@Input() assetIdentifier: string;
@Output() cancel = new EventEmitter<boolean>();
Expand Down Expand Up @@ -57,7 +59,9 @@ export class PushPublishContentTypesDialogComponent implements OnInit {
'contenttypes.content.push_publish.push_to',
'contenttypes.content.push_publish.push_to_errormsg',
'contenttypes.content.push_publish.form.cancel',
'contenttypes.content.push_publish.form.push'
'contenttypes.content.push_publish.form.push',
'contenttypes.content.push_publish.publish_date_errormsg',
'contenttypes.content.push_publish.expire_date_errormsg'
]).subscribe();

this.initForm();
Expand Down Expand Up @@ -104,10 +108,8 @@ export class PushPublishContentTypesDialogComponent implements OnInit {
private initForm(): void {
this.form = this.fb.group({
pushActionSelected: [this.pushActions[0].value || '', [Validators.required]],
publishdate: new Date,
publishdatetime: new Date,
expiredate: new Date,
expiredatetime: new Date,
publishdate: [new Date, [Validators.required]],
expiredate: [new Date, [Validators.required]],
environment: ['', [Validators.required]],
forcePush: false
});
Expand Down

0 comments on commit 58f5262

Please sign in to comment.