Przeglądaj źródła

Merge branch 'master' of https://github.com/iapt-platform/mint

bhikkhu-kosalla-china 4 lat temu
rodzic
commit
75260f8b9b
6 zmienionych plików z 127 dodań i 23 usunięć
  1. 6 0
      app/article/article.js
  2. 6 2
      app/article/index.php
  3. 25 4
      app/article/my_collect.js
  4. 84 15
      app/db/table.php
  5. 4 0
      app/term/term.css
  6. 2 2
      package.json

+ 6 - 0
app/article/article.js

@@ -125,6 +125,9 @@ function render_article_list(article_list,collectId="",articleId="") {
 
 function set_channal(channalid) {
 	let url = "../article/index.php?id=" + _articel_id;
+	if (_collection_id != "") {
+		url += "&collection=" + _collection_id;
+	}
 	if (channalid != "") {
 		url += "&channal=" + channalid;
 	}
@@ -141,6 +144,9 @@ function set_channal(channalid) {
 }
 function setMode(mode = "read") {
 	let url = "../article/index.php?id=" + _articel_id;
+	if (_collection_id != "") {
+		url += "&collection=" + _collection_id;
+	}
 	if (_channal != "") {
 		url += "&channal=" + _channal;
 	}

+ 6 - 2
app/article/index.php

@@ -125,6 +125,10 @@ span.fancytree-title{
 span.fancytree-node{
 	display: flex;
 }
+#toc_content{
+	max-height: 25vw;
+    width: max-content;
+}
 </style>
 
 <?php
@@ -182,9 +186,9 @@ span.fancytree-node{
 		</div>
 	</div>
 	<div id="right_pannal">
-		<div class="fun_frame">
+		<div class="fun_frame" style="overflow-x: scroll;">
 			<div id = "collect_title" class="title"><?php echo $_local->gui->contents; ?></div>
-			<div id = "toc_content" class="content" style="max-height:25vw;">
+			<div id = "toc_content" class="content" >
 			</div>
 		</div>
 		<div class="fun_frame">

+ 25 - 4
app/article/my_collect.js

@@ -49,6 +49,7 @@ function my_collect_list() {
 }
 var _arrArticleList;
 var _arrArticleOrder = new Array();
+var currSelectNode;
 function my_collect_edit(id) {
 	$.get(
 		"../article/collect_get.php",
@@ -85,7 +86,7 @@ function my_collect_edit(id) {
 					html += "<div style='display:flex;'>";
 					html += "<div style='flex:2;'>" + gLocal.gui.introduction + "</div>";
 					html += "<div style='flex:8;'>";
-					html += "<input type='input' name='summary' value='" + result.summary + "'/>";
+					html += "<textarea type='input' name='summary' style='height:150px' >" + result.summary + "</textarea>";
 					html += "</div></div>";
 
 					html += "<div style='display:flex;'>";
@@ -105,8 +106,14 @@ function my_collect_edit(id) {
 						result.article_list +
 						"'/>";
 					html += "</div>";
+
+					html += "<div>";
+					html += "<button onclick='removeTocNode()'>Delete</button>";
+					html += "</div>";
+
 					html += "<div style='display:flex;'>";
 					html += "<div style='flex:4;'>";
+
 					html += "<div id='ul_article_list'>";
 					html += "</div>";
 
@@ -126,6 +133,8 @@ function my_collect_edit(id) {
 
 					$("#ul_article_list").fancytree({
 						autoScroll: true,
+						selectMode: 1, // 1:single, 2:multi, 3:multi-hier
+						checkbox: false, // Show checkboxes.
 						extensions: ["dnd"],
 						source: tocGetTreeData(_arrArticleList),
 						click: function(e, data) {
@@ -168,8 +177,13 @@ function my_collect_edit(id) {
 							}
 						},
 						activate: function(e, data) {
-			//				alert("activate " + data.node);
-						}
+			//				alert("activate " + );
+							currSelectNode = data.node;
+						},
+						select: function(e, data) {
+							// Display list of selected nodes
+							currSelectNode = data.tree.getSelectedNodes();
+						  }
 					});
 				
 
@@ -262,9 +276,16 @@ function editNode(node){
 	  });
   }
 
-var arrTocTree = new Array();
+function removeTocNode(){
+	if(confirm("Delete article and the sub article?")){
+		currSelectNode.remove();
+	}
+	
+  }
+var arrTocTree;
 var iTocTreeCurrLevel = 1;
 function getTocTreeData(){
+	arrTocTree = new Array();
 	let tree = $("#ul_article_list").fancytree("getTree");
     let d = tree.toDict(false);
 	for (const iterator of d) {

+ 84 - 15
app/db/table.php

@@ -1,10 +1,11 @@
 <?php
-		/*
-        $table->beginTransaction($query)
-			  ->set($date)
-			  ->commit();
-		*/
 require_once "../redis/function.php";
+// Require Composer's autoloader.
+//require '../../vendor/autoload.php';
+ 
+// Using Medoo namespace.
+//use Medoo\Medoo;
+
 
 class Table
 {
@@ -13,16 +14,91 @@ class Table
     protected $redis;
     protected $errorMessage;
 	protected $field_setting;
+	protected $result;
+	protected $medoo;
+	protected $redisProfix;
     function __construct($db,$table,$user="",$password="",$redis=false) {
         $this->dbh = new PDO($db, $user, $password,array(PDO::ATTR_PERSISTENT=>true));
         $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+		/*
+		$database = new Medoo([
+			// Initialized and connected PDO object.
+			'pdo' => $this->dbh,
+		 
+			// [optional] Medoo will have different handle method according to different database type.
+			'type' => 'sqlite'
+		]);
+		
+		$this->medoo = $database;
+		*/
 		$this->redis = $redis;
 		$this->table = $table;
+		$this->result = ["ok"=>true,"message"=>"","data"=>array()];
+		$this->redisProfix = $table . "/:id";
     }
-	
-	public function setField($setting){
-		$this->field_setting = $setting;
+	/*
+	public function index($columns,$where){
+		$output = $this->medoo->select(
+			$this->table,
+			$columns,
+			$where
+		);
+		$this->result["data"] = $output;
+		return $this->result;
+	}
+	public function create($data,$columns){
+		foreach ($columns as $value) {
+			# code...
+			$updateDate[$value] = $data[$value];
+		}
+		$this->medoo->insert(
+			$this->table,
+			$updateDate
+		);
+
+		$newId = $database->id;
+		$this->result["data"] = $newId;
+		return $this->result;
+	}
+	public function update($data,$columns,$where=null){
+		foreach ($columns as $value) {
+			# code...
+			$updateDate[$value] = $data[$value];
+		}
+		if($where==null){
+			$where = ["id"=>$data["id"]];
+		}
+		$this->medoo->update(
+			$this->table,
+			$updateDate,
+			$where
+		);
+
+		return $this->result;
 	}
+
+	public function get($columns,$where){
+		$output = $this->medoo->get(
+			$this->table,
+			$columns,
+			$where
+		);
+		$this->result["data"] = $output;
+		return $this->result;
+
+	}
+
+	public function delete($where){
+		$output = $this->medoo->delete(
+			$this->table,
+			$where
+		);
+		$this->result["data"] = $output->rowCount();
+		return $this->result;
+	}
+*/
+
+
 	protected function fetch($query,$params){
 		if (isset($params)) {
 			$stmt = $this->dbh->prepare($query);
@@ -58,13 +134,6 @@ class Table
 	}
 
 
-	public function syncList($time){
-
-	}
-
-	public function syncGet($time){
-
-	}
 }
 
 ?>

+ 4 - 0
app/term/term.css

@@ -977,4 +977,8 @@ pali>p {
 
 .para_mode .palitext{
 	text-indent: 2em;
+}
+
+.sent_mode>div>p {
+    border-bottom: 0.5em solid var(--btn-color);
 }

+ 2 - 2
package.json

@@ -8,10 +8,10 @@
 		"highcharts": "^9.2.2",
 		"jquery": "^3.6.0",
 		"jquery-ui": "^1.12.1",
-		"jquery.fancytree": "^2.38.0",
 		"marked": "^2.1.3",
 		"mermaid": "^8.12.0",
 		"tributejs": "^5.1.3",
-		"vue": "^3.2.8"
+		"vue": "^3.2.8",
+		"jquery.fancytree": "^2.38.0"
 	}
 }