Change name of EventObject fields - fullcalendar

Is there a possibility to set a specific field name for event title?
e.g.
$('#calendar').fullCalendar({
events: [
{
name : 'event1', //instead of 'title'
start_date : '2010-01-01' //instead of 'start'
}
]
});

Your Event Object will have standard fields and see here at the bottom of the page. You can have any additional non-standard fields. So you could add a name field but you would still need a title field as it is required.
In addition to the fields above, you may also include your own non-standard fields in each Event Object. FullCalendar will not modify or delete these fields. For example, developers often include a description field for use in callbacks such as eventRender.
You also have the option to set a custom name for the startParam, endParam and timezoneParam. So you can use these to change your start and end to start_date and end_date.

Related

How to update djangocms-blog post extensions fields position?

I have some post extensions adding new fields in my Posts objects.
I created the migration, launched my website, and I thought that maybe customizing the fieldsets would allow me to customize the position of the post extensions fieldset too.
That didn't seems to be the case. I created a new SmallIntegerField named my_new_field in a PostExtension class that I registered using blog_admin.register_extension(PostExtensionInline) (I also created the PostExtensionInline class by following the doc).
I added a breakpoint in my update_fields function that I'm using to update the order of the fields of my posts (see this SO question and its answer for more infos on this), and I can't find any mention to my_new_field in the fgets arg:
Quit the server with CONTROL-C.
> /home/me/my-test-app/my_test_app/update_fields.py(3)update_fields()
-> return fsets
(Pdb) l
1 def update_fields(fsets, request, obj):
2 breakpoint()
3 -> return fsets
[EOF]
(Pdb) fsets
[(None, {'fields': ['title', 'subtitle', 'slug', 'publish', 'categories', 'abstract', 'sites', 'author']}), ('Info', {'fields': [['tags', 'related'], ['date_published', 'date_published_end', 'date_featured'], 'app_config', 'enable_comments'], 'classes': ('collapse',)}), ('Images', {'fields': [['main_image', 'main_image_thumbnail', 'main_image_full']], 'classes': ('collapse',)}), ('SEO', {'fields': [['meta_description', 'meta_title', 'meta_keywords']], 'classes': ('collapse',)})]
How can I update my field position? (see edit below)
edit: I can't think of a way to tweak the order of the post extension fields. But I realized that my real problem (yeah yeah that's a case of XYproblem) is that I want conditional inline (only include the post extension for a certain apphook that's using a defined BlogConfig instance.
How to conditionally add the inline post extension form/fields to my admin create form based on the BlogConfig instance?
So I figured it out (and it's not pretty, but it works).
I added those lines in my admin.py:
# replace PostAdmin get_inlines function in order to hide event_date on regular blog posts
from djangocms_blog.admin import PostAdmin
from .misc import get_inline_instances as patched_get_inline_instances
PostAdmin.get_inline_instances = patched_get_inline_instances
And here's my code on misc.py:
def get_inline_instances(self, request, obj=None):
from djangocms_blog.cms_appconfig import BlogConfig
from djangocms_blog.admin import PostAdmin
from json import loads
inline_instances = super(PostAdmin, self).get_inline_instances(request, obj)
if "app_config" in request.GET:
# get blog config instance from request
blog_config = BlogConfig.objects.filter(pk=request.GET["app_config"])
# get config from saved json
config = loads(blog_config.values()[0]["app_data"])
# get template_prefix from config
if config:
template_prefix = config['config']['template_prefix']
if template_prefix == "djangocms_blog_agenda":
return inline_instances
return []
I used the template_prefix value in a BlogConfig instance of djangocms_blog to update the code based on the request:
If we have "djangocms_blog_agenda" in the template_prefix, then return the inline instances.
If we don't have this (default BlogConfig, another BlogConfig that do not need my current post extension fields), return an empty list.
The result can be viewed here:
Blog posts list screenshot, we can see that the articles are displayed by most recent "published date" first.
We can select our blog config after a click on "Blog > Add Post...".
Agenda post creation screenshot, we can see that there's a post extension named "event date" (not present in Blog post creation screenshot).
Agenda list screenshot, we can see that the "events" are displayed by nearest future "event date" date.

MikroORM Create filter query based on a value in the database

Simply put, is it possible to create a filter query where I reference a value stored in the row?
For example:
orm.em.findOne(Job, {
status: 'active',
startDate: {
$gt: '$anotherDateField'
}
}
My goal is to have a user-input defined filter (the status), but also only bring back certain rows where the start date is greater than another column's value.
You can use custom SQL fragment
orm.em.findOne(Job, {
status: 'active',
// expr helper allows to escape strict typing of the method, so we can use `em.raw()`
[expr('startDate')]: {
$gt: orm.em.raw('another_date_field') // this will have to be column name, not property name
}
}
Note that your em needs to be typed to the one exported from driver package to have access to the em.raw() method (if you work with orm instance, you need to type that to MikroORM<YourDriver> so orm.em can be properly typed).
https://mikro-orm.io/docs/entity-manager/#using-custom-sql-fragments

put validation on page item through Dynamic Action

In this page I have put plsql code on click of Create Assignment button. There is a constraint on column "Assigned To" which usualy fires when that field left blank.
I want to put a validation so that I can get my own alert message which should be user readable. Also after that message submit process should be ignored.
I tried with field name :P11_Assignment NULL in the condition of PLSQL code in Dynamic Action but it is not working.
Please advise with a solution.
Before the PL/SQL Action add an Execute Javascript action.
You will want to use apex.message.* function like the following:
apex.message.clearErrors
apex.message.showErrors
Oracle Documentation link
Example:
apex.message.clearErrors();
if ($v("P11_Assignment").trim() == '') {
apex.message.showErrors({
type: "error",
location: [ "page", "inline" ],
pageItem: "P11_Assignment",
message: 'Must have a Value',
unsafe: false
});
return false; /* This is important, it stops the next action(s) from running. */
}
putting IF ELSE condition in the begining of plsql code
IF field is empty THEN don't execute the plsql code and change the field item to a value.
On value change of that item put an alert message in Dynamic Action.

Symfony form Event Listener for collection fields

I use event listener for change data dynamically based on user inputs. Each time I use PRE_SET_DATA and PRE_SUBMIT events for set data and fields choices. Here is the simple example of actions from PRE_SUBMIT:
// Pre set share locations by share day
if (array_key_exists('shares', $data)) {
foreach ($data['shares'] as $key => $share) {
if ($share['pickUpDay'] !== null) {
$shareType = $form->get('shares')->get($key);
$locations = $this->em->getRepository('AppBundle:Member\Location')->getLocationsByDay($client, $data['shares'][$key]['pickUpDay']);
$this->addLocationField($shareType, $locations);
}
}
}
Not matter what inside addLocationField function, it works right.
When I do $form->get('shares'), its my collection field, then I need to ->get(child) of this collection and set fields data and choices straight to this child. By when I add collection dynamically, Symfony shows error:
Child "n" does not exist.
And this problem happens only when I try to get data of new collection that was added dynamically. So I can't get to a collection field and change choices, so I receive error that my new value is not in a choice list.
Interesting that $data['shares'] have all data for new collection elements, but $form->get('shares') haven`t:
var_dump(count($event->getData()['shares'])) - return 1;
var_dump(count($form->get('shares'))) - return 0;
Is that mean that my PRE_SUBMIT works before Symfony collection functionality happen?
Someone know how to fix it?
I know your question is "old" and you probably found a solution but you were in the right direction when you said :
Is that mean that my PRE_SUBMIT works before Symfony collection functionality happen?
Your new collection is not submitted yet and it is not present in the model see this part of the doc
To make what you want to, you should use the SUBMIT event
NB : You can't add any field on POST_SUBMIT

Meteor simple-schema: how to get the value of another field that isn't set

I'd like to know the value of another field even when that field hasn't been set in this update, but is part of the document and was set in the past. Is this possible using aldeed:simple-schema?
No. Unless the other field is included in the modifier you have to lookup the document using Collection.findOne and get the field value from that.
Simple you can use for instance:
AutoForm.getFieldValue('profileInformation.dateOfBirth');
age: {
type: String,
optional: true,
defaultValue : function(){
return AutoForm.getFieldValue('profileInformation.dateOfBirth');
}
}

Resources