Skip to content

Commit

Permalink
Formatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
o-seliuchenko committed Nov 25, 2020
1 parent 6d76efe commit 5bf161b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions spec/service-provider-needs/AddNeedSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ describe('Add individual Need', () => {
'Keywords': [ 'keywordA', 'keywordB', 'keywordC' ],
'CustomMessage': 'custom message',
'ClientGroupKeys': [],
'NeededDate': moment('2020-11-25').format('YYYY-MM-DD'),
'EndDate': moment('2020-11-27').format('YYYY-MM-DD')
'NeededDate': new Date('2020-11-25'),
'EndDate': new Date('2020-11-27')
}
var postAsExpected = ajaxStub.withArgs(endpoint, payload).calledOnce
expect(postAsExpected).toBeTruthy()
Expand Down
4 changes: 2 additions & 2 deletions spec/service-provider-needs/EditNeedSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ describe('Editing Service Provider Need', () => {
'Keywords': ['keywordA', 'keywordB', 'keywordC'],
'CustomMessage': 'custom message',
'ClientGroupKeys': ['cg-1', 'cg-2'],
'NeededDate': moment('2020-11-25').format('YYYY-MM-DD'),
'EndDate': moment('2020-11-27').format('YYYY-MM-DD')
'NeededDate': new Date('2020-11-25'),
'EndDate': new Date('2020-11-27')
}
).returns(fakePutResolution())

Expand Down
1 change: 0 additions & 1 deletion src/js/models/ListingBaseViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ function ListingBaseViewModel () {

// We generate this for retrieving the not cached item
let syntaxSugar = new Date().getTime()

ajax
.get(getUrl.fullUrl + `&unique=${syntaxSugar}`)
.then(function (result) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/models/Need.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Need (data) {
self.totalResponses = ko.observable(0)

self.startDate.subscribe((value) => {
if(moment(value) > moment(self.endDate()).add('-1', 'days')){
if (moment(value) > moment(self.endDate()).add('-1', 'days')) {
self.endDate(moment(value).add('1', 'days').format(dateFormat))
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/js/models/content-pages/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Model = function () {

self.save = function () {
browser.loading()
const payload = {
const payload = {
title: self.title(),
type: self.type(),
body: self.body(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function EditServiceProviderNeed () {
self.need = ko.observable()
self.dateFormat = dateFormat
self.moment = moment

const providerId = getUrlParameter.parameter('providerId')
const needId = getUrlParameter.parameter('needId')

Expand Down
25 changes: 13 additions & 12 deletions src/js/models/service-providers/listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class ServiceProvider {
this.publishedLabel = ko.computed(function () { return this.isPublished() ? 'published' : 'disabled' }, this)
this.publishedLabelClass = ko.computed(function () { return this.isPublished() ? 'status status--true' : 'status status--false' }, this)
this.togglePublishButtonLabel = ko.computed(function () { return this.isPublished() ? 'disable' : 'publish' }, this)
this.notes = sp.notes ? ko.observableArray(sp.notes.map((e) => { return new Note(e) }).reverse()) : ko.observableArray() }
this.notes = sp.notes ? ko.observableArray(sp.notes.map((e) => { return new Note(e) }).reverse()) : ko.observableArray()
}
}

class Note {
Expand Down Expand Up @@ -142,16 +143,16 @@ function DashboardModel () {

if (!self.isOpenNotesInputModal()) {
ajax.put(self.endpointBuilder.serviceProviders(self.currentServiceProvider().key).build() + '/is-published',
{
'IsPublished': !self.currentServiceProvider().isPublished(),
'Note': {
CreationDate: self.note().creationDate().toISOString(),
// We must use new Date() for passing date with timezone. In the database this date should be saved in utc format (00 hours 00 minutes).
Date: new Date(self.note().date()),
StaffName: self.note().staffName(),
Reason: self.note().reason()
}
})
{
'IsPublished': !self.currentServiceProvider().isPublished(),
'Note': {
CreationDate: self.note().creationDate().toISOString(),
// We must use new Date() for passing date with timezone. In the database this date should be saved in utc format (00 hours 00 minutes).
Date: new Date(self.note().date()),
StaffName: self.note().staffName(),
Reason: self.note().reason()
}
})
.then(function (result) {
self.updateServiceProvider(self.currentServiceProvider(), self.invertPublished)
if (!self.currentServiceProvider().isPublished() && (self.currentServiceProvider().notes().length === 1 || moment(self.note().date()).isSame(moment().format(dateFormat)))) {
Expand All @@ -176,7 +177,7 @@ function DashboardModel () {
if (sp.key === serviceProvider.key) {
if (serviceProvider.isPublished()) {
sp.notes().unshift(self.note())
}
}
invert(sp, serviceProvider)
}
return sp
Expand Down

0 comments on commit 5bf161b

Please sign in to comment.