Selaa lähdekoodia

dashboard: amélioration + intégration home

idleman 1 vuosi sitten
vanhempi
commit
69f596e2aa

+ 2 - 6
plugin/dashboard/action.php

@@ -42,17 +42,13 @@
 
 		if(!empty($_['uid'])) $filters['uid'] = $_['uid'];
 
-
-		// $dashboard = new Dashboard();
-		// $dashboard->uid = $myUser->login;
-		// $dashboard->scope = "home";
-		// $dashboard->save();
-
 		$dashboard = Dashboard::load($filters);
 		if(!$dashboard) throw new Exception("Dashboard introuvable");
 
 		$widget = new DashboardWidget();
 		$widget->dashboard = $dashboard->id;
+		if(isset($_['row'])) $widget->row = $_['row'];
+		if(isset($_['column'])) $widget->column = $_['column'];
 		$widget->save();
 
 		$row = $widget->toArray();

+ 34 - 0
plugin/dashboard/css/main.css

@@ -11,3 +11,37 @@
 /* formulaire d'édition de tableau de bord */
 .plugin-dashboard .dashboard-form {}
 
+
+
+html.module-index,
+.module-index body{
+	background-color: #efefef;
+}
+
+.dashboard-placeholder{
+	transition: background 0.2s ease-in-out;
+	cursor: pointer;
+	position: relative;
+	border-radius: 10px;
+}
+.dashboard-placeholder:hover{
+	background-color: #e6e6e6;
+}
+
+.dashboard-placeholder .placeholder-add{
+	display: inline-block;
+	opacity: 0;
+	text-align: center;
+	height: 100%;
+	vertical-align: bottom;
+	line-height: 100%;
+	position: absolute;
+	color: #b5b3b3;
+	top: calc(50% - 15px);
+	left: calc(50% - 15px);
+	font-size: 30px;
+	transition: opacity 0.2s ease-in-out;
+}
+.dashboard-placeholder:hover .placeholder-add{
+	opacity: 1;
+}

+ 1 - 1
plugin/dashboard/dashboard.plugin.php

@@ -18,7 +18,7 @@ function dashboard_menu(&$menuItems){
 //Cette fonction va generer une page quand on clique sur Dashboard dans menu
 function dashboard_page(){
 	global $_;
-	if(!isset($_['module']) || $_['module'] !='dashboard') return;
+	if(isset($_['module'])) return;
 	$page = !isset($_['page']) ? 'list.dashboard' : $_['page'];
 	$page = str_replace('..','',$page);
 	$file = __DIR__.SLASH.'page.'.$page.'.php';

+ 14 - 0
plugin/dashboard/js/component.js

@@ -74,6 +74,19 @@ function init_components_dashboard(input){
 		
 	});
 	
+	component.on('placeholder-click',function(placeholder){
+		$.action({
+			action : data.onAdd,
+			scope : data.scope,
+			uid : data.uid,
+			row : placeholder.row,
+			column : placeholder.column
+		},function(widget){
+			
+			component.addWidgets([widget]);
+		});
+	});
+
 	component.on('move',function(widget){
 		console.log('Widget has moved',widget);
 		$.action({
@@ -88,6 +101,7 @@ function init_components_dashboard(input){
 			widget : widget
 		});
 	}).on('delete',function(widget){
+		if(!confirm('Êtes-vous sûr de vouloir supprimer cet item?')) return true;
 		console.log('Widget has removed',widget);
 		$.action({
 			action : data.onRemove,

+ 12 - 1
plugin/dashboard/js/dashboard.js

@@ -10,7 +10,7 @@ class Dashboard {
     var grid  = '<div class="dashboard-grid" >';
 	for(var u =0 ; u<options.lineNumber;u++){
 		for(var i =0 ; i<options.columnNumber;i++){
-			grid += '<div data-row="'+u+'" data-column="'+i+'" style="grid-row: '+(u+1)+" / "+(u+1)+";grid-column: "+(i+1)+" / "+(i+1)+';padding:'+this.options.placeHolderPadding+'px;" class="dashboard-placeholder"></div>';
+			grid += '<div data-row="'+u+'" data-column="'+i+'" style="grid-row: '+(u+1)+" / "+(u+1)+";grid-column: "+(i+1)+" / "+(i+1)+';padding:'+this.options.placeHolderPadding+'px;" class="dashboard-placeholder"><i class="fa fa-plus placeholder-add"></i></div>';
 		}
 	}
 	grid  += '</div>';
@@ -67,6 +67,17 @@ class Dashboard {
 		object.resizing = null;
 	});
 
+
+		$('.dashboard-placeholder').click(function(){
+			var placeholder = $(this);
+			object.trigger('placeholder-click',{
+				element : placeholder,
+				row: placeholder.attr('data-row'),
+				column: placeholder.attr('data-column')
+			});
+		});
+
+
   }
 
   on(event,callback){

+ 9 - 1
plugin/dashboard/page.list.test.php → plugin/dashboard/page.list.dashboard.php

@@ -1,7 +1,15 @@
  <?php
-global $myUser;
+global $myUser,$conf;
 User::check_access('dashboard','read');
 require_once(__DIR__.SLASH.'Dashboard.class.php');
+
+if(Dashboard::rowCount(array('scope'=>'home','uid'=>$myUser->login))==0){
+    $dashboard = new Dashboard();
+    $dashboard->uid = $myUser->login;
+    $dashboard->scope = "home";
+    $dashboard->save();
+}
+
 ?>
 <div class="plugin-dashboard">
     <div class="row">