Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b528119

Browse files
committedDec 31, 2010
add qTip, dashboard, tweak class name and css
1 parent 3e4e38c commit b528119

23 files changed

+3010
-46
lines changed
 

‎Admin/Admin.php

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ abstract class Admin extends ContainerAware
3030
// note : don't like this, but havn't find a better way to do it
3131
protected $configuration_pool;
3232

33+
protected $code;
34+
35+
protected $label;
36+
3337
public function configure()
3438
{
3539
$this->buildFormFields();
@@ -129,9 +133,17 @@ public function getUrl($name)
129133
return $urls[$name];
130134
}
131135

132-
public function generateUrl($url, $params = array())
136+
public function generateUrl($name, $params = array())
133137
{
134-
$url = $this->getUrl($url);
138+
$url = $this->getUrl($name);
139+
140+
if(!$url) {
141+
throw new \RuntimeException(sprintf('unable to find the url `%s`', $name));
142+
}
143+
144+
if(!is_array($params)) {
145+
$params = array();
146+
}
135147

136148
return $this->container->get('router')->generate($url['url'], array_merge($url['params'], $params));
137149
}
@@ -206,14 +218,32 @@ public function configureFormFields()
206218

207219
}
208220

221+
/**
222+
* return the target objet
223+
*
224+
* @param $id
225+
* @return
226+
*/
227+
public function getObject($id)
228+
{
229+
230+
return $this->getEntityManager()
231+
->find($this->getClass(), $id);
232+
}
233+
234+
/**
235+
* build the fields to use in the form
236+
*
237+
* @throws RuntimeException
238+
* @return
239+
*/
209240
public function buildFormFields()
210241
{
211242
$this->form_fields = $this->getBaseFields($this->form_fields);
212243

213244
foreach($this->form_fields as $name => $options) {
214245

215-
if(!isset($this->form_fields[$name]['type']))
216-
{
246+
if(!isset($this->form_fields[$name]['type'])) {
217247
throw new \RuntimeException(sprintf('You must declare a type for the field `%s`', $name));
218248
}
219249

@@ -231,9 +261,19 @@ public function buildFormFields()
231261
$this->form_fields[$name]['template'] = 'BaseApplicationBundle:CRUD:edit_one_to_one.twig';
232262
}
233263

264+
if($this->form_fields[$name]['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_ONE)
265+
{
266+
$this->form_fields[$name]['template'] = 'BaseApplicationBundle:CRUD:edit_many_to_one.twig';
267+
$this->form_fields[$name]['configuration'] = $this->getConfigurationPool()
268+
->getConfigurationByClass($this->form_fields[$name]['targetEntity']);
269+
}
270+
234271
if($this->form_fields[$name]['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY)
235272
{
236273
$this->form_fields[$name]['template'] = 'BaseApplicationBundle:CRUD:edit_many_to_many.twig';
274+
$this->form_fields[$name]['configuration'] = $this->getConfigurationPool()
275+
->getConfigurationByClass($this->form_fields[$name]['targetEntity']);
276+
237277
}
238278
}
239279

@@ -261,6 +301,11 @@ public function buildFormFields()
261301
return $this->form_fields;
262302
}
263303

304+
/**
305+
* build the field to use in the list view
306+
*
307+
* @return void
308+
*/
264309
public function buildListFields()
265310
{
266311
$this->list_fields = $this->getBaseFields($this->list_fields);
@@ -281,8 +326,7 @@ public function buildListFields()
281326
}
282327

283328
// fix template for mapping
284-
if($this->list_fields[$name]['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_ONE)
285-
{
329+
if($this->list_fields[$name]['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_ONE) {
286330
$this->list_fields[$name]['template'] = 'BaseApplicationBundle:CRUD:list_many_to_one.twig';
287331
$this->list_fields[$name]['configuration'] = $this->getConfigurationPool()
288332
->getConfigurationByClass($this->list_fields[$name]['targetEntity']);
@@ -351,6 +395,8 @@ public function getChoices($description)
351395
public function getForm($object, $fields)
352396
{
353397

398+
$this->container->get('session')->start();
399+
354400
$form = new Form('data', $object, $this->container->get('validator'));
355401

356402
foreach($fields as $name => $description) {
@@ -378,6 +424,7 @@ public function getForm($object, $fields)
378424

379425
break;
380426

427+
case \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_ONE:
381428
case \Doctrine\ORM\Mapping\ClassMetadataInfo::ONE_TO_ONE:
382429

383430
$transformer = new \Symfony\Bundle\DoctrineBundle\Form\ValueTransformer\EntityToIDTransformer(array(
@@ -475,4 +522,24 @@ public function getConfigurationPool()
475522
{
476523
return $this->configuration_pool;
477524
}
525+
526+
public function setCode($code)
527+
{
528+
$this->code = $code;
529+
}
530+
531+
public function getCode()
532+
{
533+
return $this->code;
534+
}
535+
536+
public function setLabel($label)
537+
{
538+
$this->label = $label;
539+
}
540+
541+
public function getLabel()
542+
{
543+
return $this->label;
544+
}
478545
}

‎Admin/Pool.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,28 @@ class Pool
2222

2323
public function addConfiguration($code, $configuration)
2424
{
25+
$configuration['code'] = $code;
26+
2527
$this->configuration[$code] = $configuration;
2628
}
2729

30+
public function getGroups()
31+
{
32+
33+
$groups = array();
34+
35+
foreach($this->configuration as $configuration) {
36+
37+
if(!isset($groups[$configuration['group']])) {
38+
$groups[$configuration['group']] = array();
39+
}
40+
41+
$groups[$configuration['group']][$configuration['code']] = $this->getInstance($configuration['code']);
42+
}
43+
44+
return $groups;
45+
}
46+
2847
/**
2948
* The admin classes are lazy loaded to avoid overhead
3049
*
@@ -77,6 +96,8 @@ public function getInstance($code)
7796
$this->instances[$code] = new $class;
7897
$this->instances[$code]->setContainer($this->getContainer());
7998
$this->instances[$code]->setConfigurationPool($this);
99+
$this->instances[$code]->setCode($code);
100+
$this->instances[$code]->setLabel($this->configuration[$code]['label']);
80101
$this->instances[$code]->configure();
81102
}
82103

‎Controller/CRUDController.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function batchActionDelete($idx)
7070
->getQuery()
7171
->execute();
7272

73+
7374
foreach($objects as $object) {
7475
$em->remove($object);
7576
}
@@ -82,7 +83,7 @@ public function batchActionDelete($idx)
8283

8384
public function deleteAction($id)
8485
{
85-
86+
// todo
8687
}
8788

8889
public function editAction($id)
@@ -96,7 +97,7 @@ public function editAction($id)
9697
$object = $id->getData();
9798
$form = $id;
9899
} else {
99-
$object = $this->configuration->getEntityManager()->find($this->configuration->getClass(), $id);
100+
$object = $this->configuration->getObject($id);
100101

101102
if(!$object) {
102103
throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
@@ -125,7 +126,7 @@ public function updateAction()
125126
$id = $this->get('request')->get('id');
126127

127128
if(is_numeric($id)) {
128-
$object = $this->configuration->getEntityManager()->find($this->configuration->getClass(), $id);
129+
$object = $this->configuration->getObject($id);
129130

130131
if(!$object) {
131132
throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
@@ -149,6 +150,10 @@ public function updateAction()
149150
$this->configuration->getEntityManager()->persist($object);
150151
$this->configuration->getEntityManager()->flush($object);
151152

153+
if($this->get('request')->isXmlHttpRequest()) {
154+
return $this->createResponse('ok');
155+
}
156+
152157
// redirect to edit mode
153158
return $this->redirect($this->configuration->generateUrl('edit', array('id' => $object->getId())));
154159
}
@@ -182,14 +187,15 @@ public function batchAction()
182187
return call_user_func(array($this, $final_action), $idx);
183188
}
184189

185-
public function createAction($form = null)
190+
public function createAction($id = null)
186191
{
187192
$this->get('session')->start();
188193

189194
$fields = $this->configuration->getFormFields();
190195

191-
if($form instanceof Form) {
192-
$object = $form->getData();
196+
if($id instanceof Form) {
197+
$object = $id->getData();
198+
$form = $id;
193199
} else {
194200
$class = $this->configuration->getClass();
195201
$object = new $class;

‎Controller/CoreController.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sonata package.
5+
*
6+
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Bundle\BaseApplicationBundle\Controller;
13+
14+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
15+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
16+
17+
use Symfony\Component\Form\Iterator\RecursiveFieldsWithPropertyPathIterator;
18+
19+
class CoreController extends Controller
20+
{
21+
22+
public function retrieveFormFieldElementAction($code, $element_id)
23+
{
24+
25+
// todo : refactor the code into inside the admin
26+
$admin = $this->container
27+
->get('base_application.admin.pool')
28+
->getInstance($code);
29+
30+
if(is_numeric($this->get('request')->get('object_id'))) {
31+
$object = $this->configuration->getObject($this->get('request')->get('object_id'));
32+
} else {
33+
$class = $admin->getClass();
34+
$object = new $class;
35+
}
36+
37+
if(!$object) {
38+
throw new NotFoundHttpException(sprintf('unable to find the object with id : `%s`', $this->get('request')->get('object_id')));
39+
}
40+
41+
$fields = $admin->getFormFields();
42+
$form = $admin->getForm($object, $fields);
43+
44+
// bind the form so the form element will be populated with the lastest elements
45+
$form->bind($this->get('request')->get('data'));
46+
47+
$iterator = new RecursiveFieldsWithPropertyPathIterator($form);
48+
$iterator = new \RecursiveIteratorIterator($iterator);
49+
50+
$field_element = false;
51+
foreach ($iterator as $field) {
52+
53+
if($field->getId() == $element_id) {
54+
// find the targeted element
55+
$field_element = $field;
56+
}
57+
}
58+
59+
if(!$field_element) {
60+
throw new NotFoundHttpException(sprintf('unable to retrieve the form field element with id : `%s`', $element_id));
61+
}
62+
63+
// $key = $field_element->getKey();
64+
//
65+
// if(!isset($fields[$key])) {
66+
// throw new NotFoundHttpException(sprintf('unable to retrieve the form field description with key : %s', $key));
67+
// }
68+
//
69+
// $field_description = $fields[$key];
70+
71+
// render the widget
72+
// todo : fix this, the twig environment variable is not set inside the extension ...
73+
$twig = $this->get('twig');
74+
$extension = $twig->getExtension('form');
75+
$extension->initRuntime($this->get('twig'));
76+
77+
return $this->createResponse($extension->render($field_element));
78+
79+
80+
// return $this->render($field_description['template'], array(
81+
// 'configuration' => $admin,
82+
// 'field_description' => $field_description,
83+
// 'object' => $object,
84+
// 'field_element' => $field_element,
85+
// ));
86+
}
87+
88+
public function dashboardAction()
89+
{
90+
91+
return $this->render('BaseApplicationBundle:Core:dashboard.twig', array(
92+
'groups' => $this->get('base_application.admin.pool')->getGroups()
93+
));
94+
}
95+
}

‎DependencyInjection/BaseApplicationExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ public function configLoad($config, ContainerBuilder $container)
4848
$definition = new Definition('Bundle\\BaseApplicationBundle\\Admin\\Pool');
4949
$definition->addMethodCall('setContainer', array(new Reference('service_container')));
5050
foreach($config['entities'] as $code => $configuration) {
51+
if(!isset($configuration['group'])) {
52+
$configuration['group'] = 'default';
53+
}
54+
55+
if(!isset($configuration['label'])) {
56+
$configuration['label'] = $code;
57+
}
58+
5159
$definition->addMethodCall('addConfiguration', array($code, $configuration));
5260
}
5361

‎Resources/.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<routes xmlns="http://www.symfony-project.org/schema/routing"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.symfony-project.org/schema/routing http://www.symfony-project.org/schema/routing/routing-1.0.xsd">
6+
7+
<route id="base_application_dashboard" pattern="/dashboard">
8+
<default key="_controller">BaseApplicationBundle:Core:dashboard</default>
9+
</route>
10+
11+
<route id="base_application_retrieve_form_element" pattern="/core/:code/get-form-field-element/:element_id">
12+
<default key="_controller">BaseApplicationBundle:Core:retrieveFormFieldElement</default>
13+
</route>
14+
15+
</routes>

‎Resources/public/.DS_Store

0 Bytes
Binary file not shown.

‎Resources/public/base.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
jQuery(document).ready(function() {
2+
3+
4+
jQuery('div.sonata-ba-field-error').each(function(index, element) {
5+
var input = jQuery('input, textarea', element);
6+
7+
var message = jQuery('div.sonata-ba-field-error-messages', element).html();
8+
jQuery('div.sonata-ba-field-error-messages', element).html('');
9+
if(!message) {
10+
message = '';
11+
}
12+
13+
input.qtip({
14+
content: message,
15+
show: 'mouseover',
16+
hide: 'mouseout',
17+
position: {
18+
corner: {
19+
target: 'rightMiddle',
20+
tooltip: 'leftMiddle'
21+
}
22+
},
23+
style: {
24+
name: 'red',
25+
border: {
26+
radius: 2
27+
},
28+
tip: 'leftMiddle'
29+
}
30+
})
31+
});
32+
33+
});

‎Resources/public/css/colors.css

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/* General parameter */
2+
body {
3+
background-color: #f2f2f2;
4+
}
5+
6+
a {
7+
text-decoration: none;
8+
}
9+
10+
div.container {
11+
12+
}
13+
14+
div.container div.header {
15+
padding: 5px;
16+
17+
background-image: -moz-linear-gradient(-90deg, #494949, #1b1b1b);
18+
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#494949), to(#1b1b1b));
19+
20+
color: white;
21+
}
22+
23+
div.container div.header a.home {
24+
padding: 5px;
25+
26+
font-size: 2.5em;
27+
text-decoration: none;
28+
color: white;
29+
}
30+
31+
div.container div.content {
32+
padding: 5px;
33+
34+
background-color: white;
35+
}
36+
37+
div.container div.content h1 {
38+
39+
font-size:2em;
40+
border-bottom: 1px solid #cccccc;
41+
padding-bottom: 5px;
42+
color: #3d3d3d;
43+
}
44+
45+
46+
div.container div.sonata-actions ul {
47+
float: left;
48+
list-style: none;
49+
}
50+
51+
div.container div.sonata-actions li {
52+
float: left;
53+
54+
-webkit-border-radius: 4px;
55+
-moz-border-radius: 4px;
56+
border-radius: 4px;
57+
58+
box-shadow: 0px 1px 1px rgba(0,0,0, 0.5);
59+
-moz-box-shadow: 0px 1px 1px rgba(0,0,0, 0.5);
60+
-webkit-box-shadow: 0px 1px 1px rgba(0,0,0, 0.5);
61+
62+
border: 1px solid #cccccc;
63+
background: #f2f2f2;
64+
margin: 2px;
65+
}
66+
67+
div.container div.sonata-actions li a {
68+
color: black;
69+
text-decoration: none;
70+
71+
margin-left: 6px;
72+
margin-right: 6px;
73+
line-height: 15px;
74+
}
75+
76+
77+
/* Dashboard element */
78+
table.sonata-ba-list {
79+
border: 1px solid #cccccc;
80+
}
81+
82+
table.sonata-ba-list th {
83+
background-image: -moz-linear-gradient(-90deg, #f8f8f8 , #e2e2e2);
84+
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f8f8f8), to(#e2e2e2));
85+
}
86+
87+
88+
/* Form */
89+
textarea.title {
90+
font-size: 1em;
91+
width: 500px;
92+
}
93+
94+
input.title {
95+
font-size: 1em;
96+
width: 500px;
97+
}
98+
99+
div.sonata-ba-field-error input{
100+
border: 1px solid #f79992;
101+
}
102+
103+
div.sonata-ba-field-error textarea{
104+
border: 1px solid #f79992;
105+
}

‎Resources/public/css/layout.css

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
table.sonata-ba-list {
2+
width: 500px;
3+
}
4+
5+
6+
table.sonata-ba-list td {
7+
width: 75px;
8+
}
9+
10+
table.sonata-ba-list td img{
11+
vertical-align: bottom
12+
}
13+
14+
15+
table.sonata-ba-list td.sonata-ba-list-label {
16+
width: 350px;
17+
}
18+
19+
td.pager ul {
20+
float: left;
21+
list-style: none;
22+
margin: 2px;
23+
margin-left: auto;
24+
margin-right: auto;
25+
26+
}
27+
28+
td.pager ul li {
29+
float: left;
30+
}
31+
32+
33+
td.pager ul li a {
34+
border: 1px solid #cccccc;
35+
padding: 4px;
36+
margin: 2px;
37+
}

‎Resources/public/qtip/jquery.qtip-1.0.0-rc3.js

Lines changed: 2149 additions & 0 deletions
Large diffs are not rendered by default.

‎Resources/public/qtip/jquery.qtip-1.0.0-rc3.min.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/**
2+
* jquery.qtip.debug. The jQuery tooltip plugin debugger
3+
*
4+
* Debug mode logs all tooltip events and error messages to the
5+
* global $.fn.qtip.log object, as well as creates an array of
6+
* references to all tooltips on the page.
7+
*
8+
* If a console is present, such as firebug (http://getfirebug.com),
9+
* Opera's inbuilt Drangonfly, or IE8's internal Web Developer tool,
10+
* errors will be reported to the console based on your set report
11+
* mask, which is explained in details below.
12+
*
13+
*
14+
* Copyright (c) 2009 Craig Thompson
15+
* http://craigsworks.com
16+
*
17+
* Licensed under MIT
18+
* http://www.opensource.org/licenses/mit-license.php
19+
*
20+
* Launch : February 2009
21+
* Version : 1.0.0-rc3
22+
* Released: Friday 27th April, 2009 - 23:30
23+
*/
24+
25+
/* DEBUG MODE - OFF BY DEFAULT - set to true to enable debugging */
26+
$.fn.qtip.debug = true;
27+
28+
29+
if($.fn.qtip.debug)
30+
{
31+
// Create new debug constants
32+
$.fn.qtip.constants =
33+
{
34+
/* Error messages */
35+
NO_TOOLTIP_PRESENT: 'No tooltip is present on the selected element. Cannot proceed with API call.',
36+
TOOLTIP_NOT_RENDERED: 'Tooltip has not yet been rendered! Cannot proceed with API call.',
37+
NO_VALID_CONTENT: 'No valid content was provided in the options. Using blank content.',
38+
TOOLTIP_IS_DISABLED: 'Tooltip is disabled, cannot proceed with API call.',
39+
TOOLTIP_ALREADY_DISABLED: 'Tooltip is already disabled.',
40+
TOOLTIP_ALREADY_ENABLED: 'Tooltip is already enabled.',
41+
CANVAS_VML_NOT_SUPPORTED: 'Niether canvas or VML are supported, corner and tips will not be drawn.',
42+
STYLE_NOT_DEFINED: 'No such style is defined in the global styles object.',
43+
INVALID_AREA_SHAPE: 'The AREA element used as your target has an invalid area shape. Possible values are: rect, circle, poly.',
44+
CANNOT_FOCUS_STATIC: 'Focusing static elements is not possible as they don\'t have z-index properties.',
45+
CANNOT_POSITION_STATIC: 'Positioning static elements is not possible as they don\'t have left or top properties.',
46+
NO_CONTENT_PROVIDED: 'You must specify some content with which to update.',
47+
48+
/* Event messages */
49+
EVENT_RENDERED: '(Event) Tooltip has been rendered.',
50+
EVENT_SHOWN: '(Event) Tooltip has been shown.',
51+
EVENT_HIDDEN: '(Event) Tooltip has been hidden.',
52+
EVENT_FOCUSED: '(Event) Tooltip has been focused.',
53+
EVENT_DISABLED: '(Event) Tooltip has been disabled.',
54+
EVENT_ENABLED: '(Event) Tooltip has been enabled.',
55+
EVENT_DESTROYED: '(Event) Tooltip has been destroyed.',
56+
EVENT_POSITION_UPDATED: '(Event) Tooltip position has been updated.',
57+
EVENT_CONTENT_UPDATED: '(Event) Tooltip contents have been updated.',
58+
EVENT_CONTENT_LOADED: '(Event) Tooltip contents have been loaded from specified URL.',
59+
EVENT_TITLE_UPDATED: '(Event) Tooltip title has been updated.',
60+
EVENT_STYLE_UPDATED: '(Event) Tooltip style has been updated.',
61+
EVENT_WIDTH_UPDATED: '(Event) Tooltip width has been updated.'
62+
};
63+
64+
// Define qTip log object
65+
$.fn.qtip.log = {
66+
/* CONSOLE REPORTING MASK
67+
To use this functionality you need a console installed, such as firebug:
68+
http://getfirebug.com
69+
70+
This mask determines what errors are reported to the console. Possible values are:
71+
7 = Errors, warnings and messages
72+
6 = Errors and warnings
73+
5 = Errors and messages
74+
4 = Errors only
75+
3 = Warnings and messages
76+
2 = Warnings only
77+
1 = Messages only
78+
*/
79+
report: 7,
80+
81+
/* DO NOT ALTER ANYTHING BELOW HERE! */
82+
qtips: [],
83+
messages: [],
84+
errors: [],
85+
86+
/* Error handler function */
87+
error: function(type, message, method)
88+
{
89+
var self = this;
90+
91+
// Format type string
92+
switch(type)
93+
{
94+
case 1:
95+
var typeString = 'info';
96+
var addTo = 'messages';
97+
break;
98+
99+
case 2:
100+
var typeString = 'warn';
101+
var addTo = 'messages';
102+
break;
103+
104+
default: case 4:
105+
var typeString = 'error';
106+
var addTo = 'errors';
107+
break;
108+
}
109+
110+
// Format time
111+
var DateObj = new Date();
112+
var time = DateObj.getHours() + ':' +
113+
DateObj.getMinutes() + ':' +
114+
DateObj.getSeconds();
115+
116+
// Log the error into the log array
117+
$.fn.qtip.log[addTo].push({
118+
time: time,
119+
message: message,
120+
121+
api: self,
122+
callee: self[method] || method || null
123+
});
124+
125+
// If debug mode is enabled, display the error
126+
if($.fn.qtip.log.report & type > 0)
127+
{
128+
var logMessage = 'qTip '
129+
+ ((typeof self.id !== 'undefined') ? '['+self.id+']' : '')
130+
+ ': ' + message;
131+
132+
// Check console is present
133+
if(window.console) window.console[typeString](logMessage);
134+
135+
// Check for Opera Dragonfly
136+
else if($.browser.opera && window.opera.postError) window.opera.postError(logMessage);
137+
}
138+
139+
return self;
140+
}
141+
};
142+
};

‎Resources/views/CRUD/base_edit.twig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ file that was distributed with this source code.
2020
{% endblock %}
2121

2222
{% block actions %}
23-
<ul>
24-
<li><a href="{{ configuration.generateUrl('create') }}">{% trans "link_action_create" from "BaseApplicationBundle" %}</a></li>
25-
<li><a href="{{ configuration.generateUrl('list') }}">{% trans "link_action_list" from "BaseApplicationBundle" %}</a></li>
26-
</ul>
23+
<div class="sonata-actions">
24+
<ul>
25+
<li class="sonata-action-element"><a href="{{ configuration.generateUrl('create') }}">{% trans "link_action_create" from "BaseApplicationBundle" %}</a></li>
26+
<li class="sonata-action-element"><a href="{{ configuration.generateUrl('list') }}">{% trans "link_action_list" from "BaseApplicationBundle" %}</a></li>
27+
</ul>
28+
</div>
2729
{% endblock %}
2830

2931
{% block content %}

‎Resources/views/CRUD/base_edit_field.twig

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,17 @@ file that was distributed with this source code.
99
1010
#}
1111

12-
<p>
12+
<div>
1313
{% block label %}{{ field_element|render_label }} <br />{% endblock %}
14-
{% block field %}{{ field_element|render }}{% endblock %}
15-
{% block errors %}{{ field_element|render_errors }}{% endblock %}
16-
</p>
14+
15+
<div class="sonata-ba-field {% if field_element.haserrors %}sonata-ba-field-error"{% endif %}">
16+
17+
{% block field %}{{ field_element|render }}{% endblock %}
18+
19+
<div class="sonata-ba-field-error-messages">
20+
{% block errors %}{{ field_element|render_errors }}{% endblock %}
21+
</div>
22+
23+
</div>
24+
25+
</div>

‎Resources/views/CRUD/base_list.twig

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ file that was distributed with this source code.
1414
{% block title %}{% trans 'title_list' from 'BaseApplicationBundle'%}{% endblock %}
1515

1616
{% block actions %}
17-
<ul>
18-
<li><a href="{{ configuration.generateUrl('create') }}">{% trans "link_action_create" from "BaseApplicationBundle" %}</a></li>
19-
</ul>
17+
<div class="sonata-actions">
18+
<ul>
19+
<li class="sonata-action-element"><a href="{{ configuration.generateUrl('create') }}">{% trans "link_action_create" from "BaseApplicationBundle" %}</a></li>
20+
</ul>
21+
</div>
2022
{% endblock %}
2123

2224
{% block content %}
@@ -36,23 +38,25 @@ file that was distributed with this source code.
3638
{% block table_footer %}
3739
{% if pager.haveToPaginate() %}
3840
<tr>
39-
<td colspan="{{ fields|length }}">
40-
{% if pager.page != pager.previouspage %}
41-
<li><a href="{{ pager.renderLink(pager.previouspage) }}">{% trans 'link_previous_pager' from 'BaseApplicationBundle' %}</a></li>
42-
{% endif %}
43-
44-
{# Set the number of pages to display in the pager #}
45-
{% for page in pager.getLinks(5) %}
46-
{% if page == pager.page %}
47-
<li>{{ page }}</li>
48-
{% else %}
49-
<li><a href="{{ pager.renderLink(page) }}">{{ page }}</a></li>
41+
<td colspan="{{ fields|length }}" class="pager">
42+
<ul>
43+
{% if pager.page != pager.previouspage %}
44+
<li><a href="{{ pager.renderLink(pager.previouspage) }}">{% trans 'link_previous_pager' from 'BaseApplicationBundle' %}</a></li>
5045
{% endif %}
51-
{% endfor %}
5246

53-
{% if pager.page != pager.nextpage %}
54-
<li><a href="{{ pager.renderLink(pager.nextpage) }}">{% trans 'link_previous_pager' from 'BaseApplicationBundle' %}</a></li>
55-
{% endif %}
47+
{# Set the number of pages to display in the pager #}
48+
{% for page in pager.getLinks(5) %}
49+
{% if page == pager.page %}
50+
<li>{{ page }}</li>
51+
{% else %}
52+
<li><a href="{{ pager.renderLink(page) }}">{{ page }}</a></li>
53+
{% endif %}
54+
{% endfor %}
55+
56+
{% if pager.page != pager.nextpage %}
57+
<li><a href="{{ pager.renderLink(pager.nextpage) }}">{% trans 'link_previous_pager' from 'BaseApplicationBundle' %}</a></li>
58+
{% endif %}
59+
</ul>
5660
</td>
5761
</tr>
5862
{% endif %}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{#
2+
3+
This file is part of the Sonata package.
4+
5+
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
6+
7+
For the full copyright and license information, please view the LICENSE
8+
file that was distributed with this source code.
9+
10+
#}
11+
12+
13+
{#
14+
15+
This code manage the many-to-[one|many] association field popup
16+
17+
#}
18+
19+
<script>
20+
21+
// handle the add link
22+
var field_dialog_form_add_{{ configuration.code }}_{{ field_element.id }} = function(event) {
23+
event.preventDefault();
24+
25+
var a = jQuery(this);
26+
27+
field_dialog_{{ configuration.code }}_{{ field_element.id }}.html('');
28+
29+
// retrieve the form element from the related admin generator
30+
jQuery.ajax({
31+
url: a.attr('href'),
32+
success: function(html) {
33+
34+
var html = jQuery(html);
35+
36+
// populate the popup container
37+
field_dialog_{{ configuration.code }}_{{ field_element.id }}.html(html);
38+
39+
// capture the submit event to make an ajax call, ie : POST data to the
40+
// related create admin
41+
jQuery('form', field_dialog_{{ configuration.code }}_{{ field_element.id }}).submit(field_dialog_form_action_{{ configuration.code }}_{{ field_element.id }});
42+
43+
// open the dialog in modal mode
44+
field_dialog_{{ configuration.code }}_{{ field_element.id }}.dialog({
45+
height: 'auto',
46+
width: 'auto',
47+
modal: true,
48+
resizable: false
49+
});
50+
}
51+
});
52+
};
53+
54+
// handle the post data
55+
var field_dialog_form_action_{{ configuration.code }}_{{ field_element.id }} = function(event) {
56+
event.preventDefault();
57+
58+
var form = jQuery(this);
59+
60+
// the ajax post
61+
jQuery.ajax({
62+
url: form.attr('action'),
63+
type: "POST",
64+
data: form.serializeArray(),
65+
success: function(html) {
66+
// if the crud action return ok, then the element has been added
67+
// so the widget container must be refresh with the last option available
68+
if(html == 'ok') {
69+
field_dialog_{{ configuration.code }}_{{ field_element.id }}.dialog('close');
70+
71+
// reload the form element
72+
jQuery.ajax({
73+
url: '{{ url('base_application_retrieve_form_element', {
74+
'code': configuration.code,
75+
'element_id': field_element.id,
76+
'object_id': form.data.id,
77+
}) }}',
78+
data: jQuery('#field_widget_{{ configuration.code }}_{{ field_element.id}}').closest('form').serializeArray(),
79+
type: 'POST',
80+
success: function(html) {
81+
jQuery('#field_widget_{{ configuration.code }}_{{ field_element.id}}').html(html);
82+
}
83+
});
84+
85+
return;
86+
}
87+
88+
// otherwise, display form error
89+
field_dialog_{{ configuration.code }}_{{ field_element.id }}.html(html);
90+
91+
// reattach the event
92+
jQuery('form', field_dialog_{{ configuration.code }}_{{ field_element.id }}).submit(field_dialog_form_action_{{ configuration.code }}_{{ field_element.id }});
93+
}
94+
});
95+
96+
return false;
97+
}
98+
99+
100+
var field_dialog_{{ configuration.code }}_{{ field_element.id }} = jQuery("#field_dialog_{{ configuration.code }}_{{ field_element.id }}");
101+
102+
// move the dialog as a child of the root element, nested form break html ...
103+
jQuery(document).append(field_dialog_{{ configuration.code }}_{{ field_element.id }});
104+
105+
// attach event on the add link
106+
jQuery('#field_actions_{{ configuration.code }}_{{ field_element.id}} a').click(field_dialog_form_add_{{ configuration.code }}_{{ field_element.id }});
107+
108+
</script>

‎Resources/views/CRUD/edit_many_to_many.twig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,21 @@ file that was distributed with this source code.
1111

1212
{% extends 'BaseApplicationBundle:CRUD:base_edit_field.twig' %}
1313

14+
{% block field %}
15+
<div id="field_container_{{ configuration.code }}_{{ field_element.id}}">
16+
<span id="field_widget_{{ configuration.code }}_{{ field_element.id}}" >
17+
{{ field_element|render }}
18+
</span>
19+
20+
<span id="field_actions_{{ configuration.code }}_{{ field_element.id}}" >
21+
<a href="{{ field_description.configuration.generateUrl('create') }}" class="action"><img src="/bundles/baseapplication/famfamfam/add.png" alt="{% trans 'btn_add' from 'BaseApplicationBundle' %}" /></a>
22+
</span>
23+
24+
<div style="display: hidden" id="field_dialog_{{ configuration.code }}_{{ field_element.id }}">
25+
26+
</div>
27+
28+
{% include 'BaseApplicationBundle:CRUD:edit_many_association_script.twig' %}
29+
30+
</div>
31+
{% endblock %}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{#
2+
3+
This file is part of the Sonata package.
4+
5+
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
6+
7+
For the full copyright and license information, please view the LICENSE
8+
file that was distributed with this source code.
9+
10+
#}
11+
12+
{% extends 'BaseApplicationBundle:CRUD:base_edit_field.twig' %}
13+
14+
{% block field %}
15+
<div id="field_container_{{ configuration.code }}_{{ field_element.id}}">
16+
<span id="field_widget_{{ configuration.code }}_{{ field_element.id}}" >
17+
{{ field_element|render }}
18+
</span>
19+
20+
<span id="field_actions_{{ configuration.code }}_{{ field_element.id}}" >
21+
<a href="{{ field_description.configuration.generateUrl('create') }}" class="action"><img src="/bundles/baseapplication/famfamfam/add.png" alt="{% trans 'btn_add' from 'BaseApplicationBundle' %}" /></a>
22+
</span>
23+
24+
<div style="display: hidden" id="field_dialog_{{ configuration.code }}_{{ field_element.id }}">
25+
26+
</div>
27+
28+
{% include 'BaseApplicationBundle:CRUD:edit_many_association_script.twig' %}
29+
30+
</div>
31+
{% endblock %}

‎Resources/views/CRUD/list__batch.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ file that was distributed with this source code.
1111

1212
{% extends 'BaseApplicationBundle:CRUD:base_list_field.twig' %}
1313

14-
{% block field%}<input type="checkbox" name="idx" value="{{ object.id }}" />{% endblock %}
14+
{% block field%}<input type="checkbox" name="idx[]" value="{{ object.id }}" />{% endblock %}

‎Resources/views/Core/dashboard.twig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{#
2+
3+
This file is part of the Sonata package.
4+
5+
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
6+
7+
For the full copyright and license information, please view the LICENSE
8+
file that was distributed with this source code.
9+
10+
#}
11+
12+
{% extends 'BaseApplicationBundle::layout.twig' %}
13+
14+
{% block title %}{% trans 'title_dashboard' from 'BaseApplicationBundle' %}{% endblock%}
15+
{% block content %}
16+
17+
{% for code, group in groups %}
18+
<table class="sonata-ba-list">
19+
<thead>
20+
<tr>
21+
<th colspan="3">{{ code }}</td>
22+
</tr>
23+
</thead>
24+
25+
<tbody>
26+
{% for admin in group %}
27+
<tr>
28+
<td class="sonata-ba-list-label">{{ admin.label}}</td>
29+
<td><a href="{{ admin.generateUrl('create')}}"><img src="/bundles/baseapplication/famfamfam/add.png" /> {% trans 'link_add' from 'BaseApplicationBundle' %}</a></td>
30+
<td><a href="{{ admin.generateUrl('list')}}"><img src="/bundles/baseapplication/famfamfam/application_view_list.png" />{% trans 'link_list' from 'BaseApplicationBundle' %}</a></td>
31+
</tr>
32+
{% endfor %}
33+
</tbody>
34+
</table>
35+
{% endfor %}
36+
37+
{% endblock %}

‎Resources/views/layout.twig

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,79 @@ For the full copyright and license information, please view the LICENSE
88
file that was distributed with this source code.
99
1010
#}
11+
<!DOCTYPE html>
12+
<html>
13+
<head>
14+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1115

12-
{% block actions %}{% endblock %}
16+
<!-- jQuery code -->
17+
<link rel="stylesheet" href="/bundles/jquery/themes/flick/jquery-ui-1.8.6.custom.css" type="text/css" media="all" />
18+
<script src="/bundles/jquery/jquery-1.4.4.js" type="text/javascript"></script>
19+
<script src="/bundles/jquery/jquery-ui-1.8.6.custom.js" type="text/javascript"></script>
20+
<script src="/bundles/jquery/jquery-ui-i18n.js" type="text/javascript"></script>
1321

14-
<h1>{% block title %}{% endblock %}</h1>
22+
<!-- page code -->
23+
<link rel="stylesheet" href="/bundles/page/blueprint/screen.css" type="text/css" media="screen, projection">
24+
<link rel="stylesheet" href="/bundles/page/blueprint/print.css" type="text/css" media="print">
25+
<!--[if lt IE 8]><link rel="stylesheet" href="/bundles/page/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
1526

16-
{% block content %}
27+
<script src="/bundles/page/page.js" type="text/javascript"></script>
28+
<link rel="stylesheet" href="/bundles/page/page.css" type="text/css" media="all">
1729

18-
{% block preview %}{% endblock %}
30+
<!-- base application asset -->
31+
<link rel="stylesheet" href="/bundles/baseapplication/css/layout.css" type="text/css" media="all">
32+
<link rel="stylesheet" href="/bundles/baseapplication/css/colors.css" type="text/css" media="all">
1933

20-
{% block form %}{% endblock %}
34+
<script src="/bundles/baseapplication/qtip/jquery.qtip-1.0.0-rc3.min.js" type="text/javascript"></script>
35+
<script src="/bundles/baseapplication/base.js" type="text/javascript"></script>
2136

22-
{% block list %}{% endblock %}
37+
<title>Administration</title>
38+
</head>
39+
<body>
40+
41+
<div class="container">
42+
<div class="span-24 last header">
43+
<div class="span-20">
44+
<a href="{{ url('base_application_dashboard') }}" class="home">Admin</a>
45+
</div>
46+
47+
<div class="span-4 last">
48+
Add here logout option / user options
49+
</div>
50+
</div>
51+
52+
<div class="span-24 last content clear">
53+
<div class="right">
54+
{% block actions %}{% endblock %}
55+
</div>
56+
57+
<h1>{% block title %}{% endblock %}</h1>
58+
</div>
59+
60+
<div class="span-24 last content clear">
61+
{% block content %}
62+
63+
<div class="sonata-ba-preview">
64+
{% block preview %}{% endblock %}
65+
</div>
66+
67+
<div class="sonata-ba-form">
68+
{% block form %}{% endblock %}
69+
</div>
70+
71+
<div class="sonata-ba-list">
72+
{% block list %}{% endblock %}
73+
</div>
74+
75+
{% endblock %}
76+
77+
</div>
78+
79+
<!-- footer -->
80+
<div class="span-24 last">
81+
82+
</div>
83+
</div>
84+
</body>
85+
</html>
2386

24-
{% endblock %}

0 commit comments

Comments
 (0)
Please sign in to comment.