I'm having some trouble when trying to create a SchedulerTaskEditor type object. I'm trying to add some custom fields in the generalTab of the SchedulerTaskEditor. This is what I'm doing:
Yeah we saw the EditEvent option before, but we wanted to have multiple tabs on the editor. It seemed like tabs was only supported on the TaskEdit. Is that correct?
If I understood you correctly, if we want to programmatically trigger an edit modal, we have to use the EditEvent and not the TaskEdit. Which means the editor cannot have tabs?
This would be a deep customization in the EventEdit configuration using the editorConfig option to reconfigure the child items to the editor to be as you want them:
{
features : {
eventEdit : {
editorConfig : {
// We're planning to have only *one* child - a TabPanel
// so make it fit exactly into the content element
layout : 'fit',
items : {
// Null out *all* the provided defaults and add a TabPanel
nameField : null,
resourceField : null,
startDateField : null,
startTimeField : null,
endDateField : null,
endTimeField : null,
// We knocked out all inputs above, now add a TabPanel
tabs : {
type : 'tabpanel',
items : {
generalTab : {
title : 'General',
items : {
// You have to put all your inputs in here
}
},
yourExtraTab : {
title : 'Extra stuff'
}
}
}
}
}
}
}
}
To the original question. Although it is not recommended way to create an instance of the editor in the application, it would work if the configuration has a proper structure. The default configuration can be found in SchedulerPro/lib/SchedulerPro/widget/SchedulerTaskEditor.js and if you take that, pass it as the config object to new SchedulerTaskEditor it will work.
From this point on you customize it to your needs.
NOTE: It is still not optimal to create an instance for the purposes of customization.
I have tested the approach in percent-done SchedulerPro demo with this code in app.js:
import '../_shared/shared.js'; // not required, our example styling etc.
import SchedulerPro from '../../lib/SchedulerPro/view/SchedulerPro.js';
import '../../lib/Scheduler/column/ResourceInfoColumn.js';
import SchedulerTaskEditor from '../../lib/SchedulerPro/widget/SchedulerTaskEditor.js';
// Import the percent bar feature
import '../../lib/SchedulerPro/feature/PercentBar.js';
import WidgetHelper from '../../lib/Core/helper/WidgetHelper.js';
const taskEditor = new SchedulerTaskEditor({
items : [
{
type : 'tabpanel',
defaultType : 'formtab',
ref : 'tabs',
flex : '1 0 100%',
autoHeight : true,
layoutConfig : {
alignItems : 'stretch',
alignContent : 'stretch'
},
items : {
generalTab : {
title : 'Details',
items : {
nameField : {
type : 'textfield',
label : 'Appointment description'
}
}
},
predecessorsTab : {
type : 'predecessorstab',
weight : 200
},
successorsTab : {
type : 'successorstab',
weight : 300
},
// Replaced with combo on general tab
//{ type : 'resourcestab', weight : 400 },
advancedTab : {
type : 'scheduleradvancedtab',
weight : 500
},
notesTab : {
type : 'notestab',
weight : 600
}
}
}
]
});
WidgetHelper.append([
{
type : 'button',
// text : 'Open editor',
cls : 'b-tool',
icon : 'b-fa-edit',
onAction() {
taskEditor.loadEvent(scheduler.taskStore.first);
taskEditor.showBy({
target : this.element,
align : 'l-r',
offset : 5
});
}
}
], { insertFirst : document.getElementById('tools') || document.body });
const scheduler = new SchedulerPro({
// A Project holds the data and the calculation engine for Scheduler Pro. It also acts as a CrudManager, allowing
// loading data into all stores at once
project : {
autoLoad : true,
transport : {
load : {
url : './data/data.json'
}
},
// This config enables response validation and dumping of found errors to the browser console.
// It's meant to be used as a development stage helper only so please set it to false for production systems.
validateResponse : true
},
appendTo : 'container',
startDate : '2020-03-23',
endDate : '2020-03-26',
rowHeight : 70,
barMargin : 22,
eventStyle : 'rounded',
resourceImagePath : '../_shared/images/users/',
// Custom view preset, with more compact display of hours
viewPreset : {
base : 'hourAndDay',
tickWidth : 15,
headers : [
{
unit : 'day',
dateFormat : 'ddd DD/MM' //Mon 01/10
},
{
unit : 'hour',
dateFormat : 'h'
}
]
},
features : {
columnLines : false,
dependencies : false,
// Enable the percent bar feature
percentBar : true
},
columns : [
{
type : 'resourceInfo',
text : 'Worker',
showEventCount : true
}
]
});