Our pure JavaScript Scheduler component


Post by melazhadi »

Hello,
I have a webservice that returns the holidays and to deal with this I used TimeSpan my problem is that the web service returns the date of the holiday and its wording
{
				"val": "2019-05-08",
				"lib": "Victoire du 8 mai 1945"
			},
so they will have given me a default durationunit, duration and keys
{
				"val": "2019-08-15",
				"lib": "Assomption",
				"cls": "lunch",
				"duration": 1,
				"durationUnit": "day"
			},
class Holiday extends TimeSpan {
	static get fields() {
		return [{
				name: 'startDate',
				dataSource: "val",
				type: 'date'
			},
			{
				name: 'name',
				dataSource: "lib"
			}
		]
	}
}
what should I do
thank you

Post by mats »

Just set the defaultValue you want on the fields:
class Holiday extends TimeSpan {
	static get fields() {
		return [{
				name: 'startDate',
				dataSource: "val",
				type: 'date'
			},
			{
				name: 'name',
				dataSource: "lib"
			},
			{
				name : 'duration' ,
				defaultValue : 1
			},
			...
		]
	}
}

Post by melazhadi »

Hello,
my data.json file
"timeRanges": {
		"rows": [{
				"val": "2019-05-01",
				"name": "Fête du Travail"
			}]}
Holiday Class
class Holiday extends TimeSpan {
	static get fields() {
		return [{
				name: 'startDate',
				dataSource: "val",
				type: 'date'
			},
			{
				name: 'name',
				dataSource: "lib"
			},
			{
				name: 'duration',
				defaultValue: 1
			},
			{
				name: 'cls',
				defaultValue: 'lunch'
			},
			{
				name: 'durationUnit',
				defaultValue: 'day'
			},
		]
	}
}
	timeRangesFeature: true,

when I made this configuration I had this problem
scheduler.module.js?8ef5:9 Uncaught TypeError: Cannot read property 'getTime' of null
    at Function.value (scheduler.module.js?8ef5:9)
    at TimeAxis.value (scheduler.module.js?8ef5:9)
    at TimeRanges.renderRange (scheduler.module.js?8ef5:9)
    at TimeRanges.value (scheduler.module.js?8ef5:9)
    at TimeRanges.onStoreChanged (scheduler.module.js?8ef5:9)
    at Store.value (scheduler.module.js?8ef5:9)
    at Store.set (scheduler.module.js?8ef5:9)
    at CrudManager.value (scheduler.module.js?8ef5:9)
    at CrudManager.loadDataToStore (scheduler.module.js?8ef5:9)
    at eval (scheduler.module.js?8ef5:9)

Thanks for your help

Post by melazhadi »

the problem occurs because of startDate when i make it work but the reverse no you can help me so it does not take the default values ​​that i have emitted

Post by mats »

Please provide a full test case we can inspect.

Post by melazhadi »

You will find attached the complete project

for you detail even more I try to display the holidays I've already displayed when data.json contains
	{
				"startDate": "2019-06-10",
				"name": "Lundi de Pentecôte",
				"cls": "lunch",
				"duration": 1,
				"durationUnit": "day"
			},
but for me the webservice answers me of this form
{
				"val": "2019-05-01",
				"name": "Fête du Travail"
			},
and what I try to display but I always find a problem
Attachments
planningEquipe.zip
(4.53 MiB) Downloaded 114 times

Post by mats »


Post by melazhadi »

can you still specify where I need to put these instructions

Post by mats »

please see the docs links I gave?
timeRanges : {
     store : {
         modelClass : yourModel
     }
}

Post by melazhadi »

always I receive the same exception
vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property 'getTime' of null
    at Function.value (scheduler.module.js?8ef5:9)
    at TimeAxis.value (scheduler.module.js?8ef5:9)
    at TimeRanges.renderRange (scheduler.module.js?8ef5:9)
    at TimeRanges.value (scheduler.module.js?8ef5:9)
    at TimeRanges.value (scheduler.module.js?8ef5:9)
    at TimeAxisViewModel.value (scheduler.module.js?8ef5:9)
    at TimeAxisViewModel.value (scheduler.module.js?8ef5:9)
    at TimeAxisViewModel.value (scheduler.module.js?8ef5:9)
    at TimeAxis.value (scheduler.module.js?8ef5:9)
    at TimeAxis.endreconfigure (scheduler.module.js?8ef5:9)

Post Reply