Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty Calendar - when no data #14

Open
leenasn opened this issue Jul 19, 2018 · 3 comments
Open

Empty Calendar - when no data #14

leenasn opened this issue Jul 19, 2018 · 3 comments

Comments

@leenasn
Copy link

leenasn commented Jul 19, 2018

Hi,

Thank you for the plugin. One thing I noticed when there are no data to show, I expect it to render an empty calendar. But it instead renders "No data found" message, the std. Active Admin message. Can you let me know what can be done to render an empty calendar?

Thanks,
Leena

@gbisheimer
Copy link
Contributor

Hi @leenasn.

This is because Active Admin renders the "No data found" message before sending instead of calling the index renderer. /active_admin/views/pages/index.rb#L55

The functionality you need can be accomplished rewriting the render_blank_slate method.

@leenasn
Copy link
Author

leenasn commented Jul 19, 2018

@gbisheimer thanks for the quick response. I will try overriding render_blank_slate method.

Another question: how can I pass a scope or a condition ti filter the model? For eg: I am getting all the appointments that the current logged in user has access to. My configuration is:

`
index_as_calendar ({ ajax: true,

  includes: [:practitioner],

  start_date: :starts_at,

  end_date: :ends_at
 }) do | appointment |

 {
   id: appointment.id,

   title: appointment.member_name,

   start: appointment.starts_at,

   end: appointment.ends_at,

   url: admin_appointment_path(appointment),

   tooltip: {

     title: "Booking for #{appointment.practitioner.name} Therapist #{appointment.therapist.name}",

     text: appointment.details

   }

}

end
`
It returns all the appointments for the given start, end date range. I want to restrict it to only the appointments the logged in user has access to. How can I do that? It is not clear from the documentation.

Thanks,
Leena

@sapraaman
Copy link

@gbisheimer thanks for the quick response. I will try overriding render_blank_slate method.

Another question: how can I pass a scope or a condition ti filter the model? For eg: I am getting all the appointments that the current logged in user has access to. My configuration is:

`
index_as_calendar ({ ajax: true,

  includes: [:practitioner],

  start_date: :starts_at,

  end_date: :ends_at
 }) do | appointment |

 {
   id: appointment.id,

   title: appointment.member_name,

   start: appointment.starts_at,

   end: appointment.ends_at,

   url: admin_appointment_path(appointment),

   tooltip: {

     title: "Booking for #{appointment.practitioner.name} Therapist #{appointment.therapist.name}",

     text: appointment.details

   }

}

end
`
It returns all the appointments for the given start, end date range. I want to restrict it to only the appointments the logged in user has access to. How can I do that? It is not clear from the documentation.

Thanks,
Leena

For anyone still looking for the solution, you can check permission inside the block, and return empty hash if user does not have requisite privileges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants