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

Added custome js and css to the widget edit page #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/Controller/DbviewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ function edit($id = null) {
$dashboard_id = $this->request->data['Dbview']['dashboard_id'];
$dashboards = $this->Dbview->Dashboard->find('list');
$this->set(compact('dashboards', 'dashboard_id'));

$dashboard = $this->Dashboard->read(null, $dashboard_id);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no need for a second DB query here. $this->request->data['Dashboard'] should have the associated dashboard

$this->set('dashboard', $dashboard);
}

function update($id = null) {
Expand Down
7 changes: 7 additions & 0 deletions app/View/Dbviews/edit.ctp
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<?php
$this->Html->scriptBlock($dashboard['Dashboard']['javascript'], array('inline' => false, 'safe' => false));
if ($dashboard['Dashboard']['css'] != null) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw you use this pattern before. Keep it DRY. You can create a helper, something like NullBlocks, etc. that delegates to Blocks

//If css is null tag() will only print out the start tag
$this->Blocks->append('css', $this->Html->tag('style', $dashboard['Dashboard']['css'], array('type' => 'text/css')));
}
?>
<style type="text/css">
.CodeMirror {
height: auto;
Expand Down