Our pure JavaScript Scheduler component


Post by alexsbf »

I want to use JSON from Mongo in my defaultConfig for my custom widget.

The reason for this is this JSON will eventually be loaded from Mongo and should be globally available.

Although I am getting a Webpack error: _JobTypesWEBPACK_IMPORTED_MODULE_1.default.map is not a function

Content.js:

...
    
import JobTypeCombo from '../js/JobTypeCombo';
JobTypeCombo.initClass();

...

JobTypes.js:

const JobTypes = {
    delivery: {
	color: 'red',
	complete: 'Delivered',
	statuses: {
	    'open': 'Awaiting delivery',
	    'closed': 'Delivered',
	}
    },
    collection: {
	complete: 'Collected',
	color: 'indigo'
    },
    problem_bike: {
	color: 'black',
	complete: 'Collected',
    }
}

export default JobTypes;    	

JobTypeCombo:

import {Combo} from "bryntum-scheduler/scheduler.umd";
import JobTypes from "./JobTypes";

export default class JobTypeCombo extends Combo {

    static get type() {
	return 'jobtypecombo';
    }

    static get defaultConfig() {

	//
	// I want to create the item array from JobTypes.
	// _JobTypes__WEBPACK_IMPORTED_MODULE_1__.default.map is not a function
	
	JobTypes.map((i, e) => {
	    console.log(e);
	})

	// return {
	//     items : [
	//         { value : 'delivery', text : 'Delivery' },
	//         { value : 'collection', text : 'Collection' },
	//         { value : 'problem_bike', text : 'Problem Bike' }
	//     ],
	// };
    }
}

Thanks for any help you can offer.


Post by pmiklashevich »

You create an object (JobTypes) and call "map" on it which is obviously does not exist. If you want to loops through the object properties, use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries

I want to use JSON from Mongo in my defaultConfig for my custom widget.

You can return an object from defaultConfig. It's supported. See the docs (make sure internal checkbox is enabled): https://www.bryntum.com/docs/scheduler/#Core/Base#property-defaultConfig-static

Combo also supports using a store. You can either load data manually to local store or use an ajax store.

Pavlo Miklashevych
Sr. Frontend Developer


Post by alexsbf »

Thank you, this solved my problem.


Post Reply