The handling of resource changed in FullCalender 4.0.
In FullCalendar 3.x I changed the resource of an event using:
event.resourceId = newResourceId;
In FullCalendar 4.0 I cannot find the right way...
My current code is:
var calendar_event = calendar.getEventById(data.event.id)
if (calendar_event) {
calendar_event.setProp('title', data.event.title)
calendar_event.setProp('resourceIds', [data.event.resourceId])
}
setProp seems to be not the correct method as afterwards the event does not reflect the change within the grid, only the title has been changed to the new one.
A setter to getResources(), e.g. setResources() does not exist.
The official documentation on https://fullcalendar.io/docs/resource-data only includes resource-fetching, not programmatically set a new one to an existing event.
The migration guide https://fullcalendar.io/docs/upgrading-from-v3 mentions only the methods setProp, setExtendedProp, setStart, setEnd, setDates, setAllDay, moveStart, moveEnd, moveDates to replace updateEvent - resources are missing.
My current workaround is to delete and add the event again:
calendar.getEventById(data.event.id).remove()
calendar.addEvent(data.event)
How to move an event to another resource without loading and initializing the whole event a second time?
Editing resources of an event has been added in version 4.0.2.
The documentation describes the usage as follows:
By ID:
var event = calendar.getEventById('1');
event.setResources([ 'a' ]); // set a single resource
event.setResources([ 'a', 'b' ]); // set multiple
By Resource:
var resourceA = calendar.getResourceById('a');
var resourceB = calendar.getResourceById('b');
var event = calendar.getEventById('1');
event.setResources([ resourceA, resourceB ]);
Related
I have two data sources
Assets
Locations
Assets has a One to Many relation with Locations
Assets has a query builder data source, AssetLocFiltered, that is set with the following:
ParentLocationKey =:ParentLocationKey
ParentLocationKey is the relation field for the locations table.
On the home page you select a location and then click a button that passes the location ID to a parameter on the ShopPageDemo page. with the following code
app.pages.ShopPageDemo.properties.ParentLocationKey =
widget.datasource.item.Id;
console.log(widget.datasource.item.Id);
app.showPage(app.pages.ShopPageDemo);
One the ShopPageDemo Page there is a table view of the AssetLocFiltered that sets the query parameter in the ondataload event with the following code:
widget.root.datasource.query.parameters.ParentLocationKey =
widget.root.properties.ParentLocationKey;
widget.root.datasource.load();
This works great. The problem is when i hit the browser refresh it seems like it clears the property in ShopPageDemo. How do I handle this browser refresh issue? I am not really sure where to start.
There is more than one way to do this; However, the approach I usually take involves deep linking. In your case, you'll need to do something like this:
1.) On the button that takes you to the next page, add this code:
var params = {
key: widget.datasource.item.Id
};
var page = app.pages.ShopPageDemo;
app.showPage(page);
google.script.history.replace(null, params, page.name);
2.) On the ShopPageDemo onAttach event handler, add the following:
google.script.url.getLocation(function(location) {
widget.root.properties.ParentLocationKey = location.parameter.key;
var ds = widget.datasource;
ds.query.parameters.ParentLocationKey = widget.root.properties.ParentLocationKey;
ds.load();
});
For better performance, I would set the ShopPageDemo datasource to NOT load automatically and also to unload its data on the onDetach event handler like this: widget.datasource.unload().
Reference:
1. https://developers.google.com/apps-script/guides/html/reference/history
2. https://developers.google.com/apps-script/guides/html/reference/url
I have three models:
Timesheets
Employee
Manager
I am looking for all timesheets that need to be approved by a manager (many timesheets per employee, one manager per employee).
I have tried creating datasources and prefetching both Employee and Employee.Manager, but I so far no success as of yet.
Is there a trick to this? Do I need to load the query and then do another load? Or create an intermediary datasource that holds both the Timesheet and Employee data or something else?
You can do it by applying a query filter to the datasource onDataLoad event or another event. For example, you could bind the value of a dropdown with Managers to:
#datasource.query.filters.Employee.Manager._equals
- assuming that the datasource of the widget is set to Timesheets.
If you are linking to the page from another page, you could also call a script instead of using a preset action. On the link click, invoke the script below, passing it the desired manager object from the linking page.
function loadPageTimesheets(manager){
app.showPage(app.pages.Timesheets);
app.pages.Timesheets.datasource.query.filters.Employee.Manager._equals = manager;
app.pages.Timesheets.datasource.load();
}
I would recommend to redesign your app a little bit to use full power of App Maker. You can go with Directory Model (Manager -> Employees) plus one table with data (Timesheets). In this case your timesheets query can look similar to this:
// Server side script
function getTimesheets(query) {
var managerEmail = query.parameters.ManagerEmail;
var dirQuery = app.models.Directory.newQuery();
dirQuery.filters.PrimaryEmail._equals = managerEmail;
dirQuery.prefetch.DirectReports._add();
var people = dirQuery.run();
if (people.length === 0) {
return [];
}
var manager = people[0];
// Subordinates lookup can look fancier if you need recursively
// include everybody down the hierarchy chart. In this case
// it also will make sense to update prefetch above to include
// reports of reports of reports...
var subortinatesEmails = manager.DirectReports.map(function(employee) {
return employee.PrimaryEmail;
});
var tsQuery = app.models.Timesheet.newQuery();
tsQuery.filters.EmployeeEmail._in = subortinatesEmails;
return tsQuery.run();
}
I'm using App insights in my ASP.NET MVC Angular application. I've inserted the JavaScript block (that I got from the Microsoft site) in my layout file in order to track the page level telemetry. I would like to add custom data (username that is in my session variable) to this telemetry. How can I do this?
For server side I know I can add custom data by using initializers, but I don't know how to do it from JavaScript.
appInsights.trackPageView
(
"page name",
"http://domain.com/pageurl.html",
{
PropertyA: object.propertyA,
PropertyB: object.propertyB
}
);
For more information: https://learn.microsoft.com/en-us/azure/application-insights/app-insights-api-custom-events-metrics#a-namepropertiesafilter-search-and-segment-your-data-with-properties
the AI JavaScript SDK has very similar concepts. In this case, you probably want a javascript telemetry initializer:
from https://learn.microsoft.com/en-us/azure/application-insights/app-insights-api-filtering-sampling
(and also https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md)
// Adding telemetry initializer.
// This is called whenever a new telemetry item
// is created.
appInsights.queue.push(function () {
appInsights.context.addTelemetryInitializer(function (envelope) {
var telemetryItem = envelope.data.baseData;
// To set custom properties:
telemetryItem.properties = telemetryItem.properties || {};
telemetryItem.properties["globalProperty"] = "boo";
// To set custom metrics:
telemetryItem.measurements = telemetryItem.measurements || {};
telemetryItem.measurements["globalMetric"] = 100;
});
});
and inside that telemetry initializer you'd set whatever values you want.
if it is user info, you can also use setAuthenticatedUserContext instead of a telemetry initializer.
I want my extension to do something everytime an item gets added to the project. This works fine for normale Projects or, with some magic (see here), for the Project Type "Website". But i cant get it to work with .xproj.
Here my current code to access the ItemAdded event (shortened)
var events = _dte.Events as Events2;
_projectItemEvents = events.ProjectItemsEvents;
_projectItemEvents.ItemAdded += ItemAdded;
_websiteItemEvents = events.GetObject ("WebSiteItemsEvents") as ProjectItemsEvents;
_websiteItemEvents.ItemAdded += ItemAdded;
_csharpItemEvents = events.GetObject ("CSharpProjectItemsEvents") as ProjectItemsEvents;
_csharpItemEvents.ItemAdded += ItemAdded;
Does anyone know how to access the ItemAdded event in case of an .xproj project type?
Edit: Edited code; The variables are all class fields and are not garbage collected, as in case of the other project types, the events are fired properly, just not in case of an .xproj.
I am trying to set the initial value in a Wijimo Autocomplete control which has been loaded from an external data source. The scenario being a form is used to create some new data and then is saved. Subsequently the data needs to be edited so it is reloaded into the form.
I can successfully use the Autocomplete on the initial form - the source list is a JSON Array of objects which is loaded into the controller. The app is using UI Router so I resolve this first.
When I save the data I serialise the selected Object from the Autocomplete control and is then saved to a Mongo DB store. When loading this data back in it is converted back to an object.
This is what the control looks like:
<wj-auto-complete
selected-index="selectedIndexCombo"
selected-item="selectedAirline"
items-source="airlineCodes"
display-member-path="Title"
placeholder="Airline Code"
max-items="50"/>
An example of the source list looks like this:
{
"#href":"\/airline.nsf\/api\/data\/collections\/name\/(LUAirlines)\/unid\/8DCD734E7BCDA24D80257C99003770C4",
"#link":
{
"rel":"document",
"href":"\/airline.nsf\/api\/data\/documents\/unid\/8DCD734E7BCDA24D80257C99003770C4"
},
"#entryid":"98-8DCD734E7BCDA24D80257C99003770C4",
"#unid":"8DCD734E7BCDA24D80257C99003770C4",
"#noteid":"FB2",
"#position":"98",
"#siblings":100,
"#form":"Airline",
"AirlineCode":"WN",
"Airline":"Southwest Airlines",
"Title":"WN - Southwest Airlines"
}
So when the form is initially created the controller property selectedAirline is correctly set with the selected Object.
So this works fine in the save function:
$scope.formData.selectedAirline = JSON.stringify($scope.selectedAirline);
But when reloading in the data:
AirlineInfoFactory.loadAirlineInfo($scope.reference).then(function success(response) {
$scope.selectedAirline = eval('(' + response.data.selectedAirline + ')');
$scope.information = response.data.information;
$scope.dataLoaded = true;
console.log($scope.selectedAirline)
$scope.selectedIndexCombo=11;
})
The autocomplete control does not bind to the selectedAirline property.
I tried using the selected-index attribute on the directive so see if I could just change it to something when the data loads but it doesnt work either. I suspect its to do with the digest loop but I am not sure.
Any ideas?
Thanks
I tried to replicate the scenario by reloading the data and setting the selectedAirline property and it works well withe latest version 32. Here is the fiddle:
http://jsfiddle.net/n1kpkcud/2/
` $scope.countries = initialList;
$scope.selectedAirline = '';
$scope.setItem = function () {
$scope.countries = reloading;
$scope.selectedAirline = 'Yemen';
}`
I would suggest you to update this fiddle so that it replicates the issue and I can suggest you accordingly.