Pārlūkot izejas kodu

support project weight

visuddhinanda 1 gadu atpakaļ
vecāks
revīzija
d5dbebc741

+ 2 - 0
api-v8/app/Http/Api/ProjectApi.php

@@ -19,6 +19,7 @@ class ProjectApi
                 'id' => $id,
                 'title' => $project->title,
                 'type' => $project->type,
+                'weight' => $project->weight,
                 'description' => $project->description,
             ];
         } else {
@@ -40,6 +41,7 @@ class ProjectApi
                         'id' => $id,
                         'title' => $project->title,
                         'type' => $project->type,
+                        'weight' => $project->weight,
                         'description' => $project->description,
                     ];
                     continue;

+ 6 - 1
api-v8/app/Http/Controllers/ProjectTreeController.php

@@ -41,11 +41,12 @@ class ProjectTreeController extends Controller
         }
         $newData = [];
         foreach ($request->get('data') as $key => $value) {
-            $newData[] = [
+            $data = [
                 'uid' => Str::uuid(),
                 'old_id' => $value['id'],
                 'title' => $value['title'],
                 'type' => $value['type'],
+
                 'res_id' => $value['res_id'],
                 'parent_id' => $value['parent_id'],
                 'path' => null,
@@ -54,6 +55,10 @@ class ProjectTreeController extends Controller
                 'created_at' => now(),
                 'updated_at' => now(),
             ];
+            if (isset($value['weight'])) {
+                $data['weight'] = $value['weight'];
+            }
+            $newData[] = $data;
         }
         foreach ($newData as $key => $value) {
             if ($value['parent_id']) {

+ 1 - 0
api-v8/app/Http/Resources/ProjectResource.php

@@ -21,6 +21,7 @@ class ProjectResource extends JsonResource
             'id' => $this->uid,
             'title' => $this->title,
             'type' => $this->type,
+            'weight' => $this->weight,
             'description' => $this->description,
             'executors_id' => json_decode($this->executors_id),
             'parent_id' => $this->parent_id,

+ 3 - 0
dashboard-v4/dashboard/src/components/api/task.ts

@@ -31,6 +31,7 @@ export interface IProject {
   id: string;
   title: string;
   description: string | null;
+  weight: number;
 }
 
 export type TTaskCategory =
@@ -141,6 +142,7 @@ export interface IProjectData {
   id: string;
   title: string;
   type: TProjectType;
+  weight: number;
   description: string | null;
   parent?: IProjectData | null;
   parent_id?: string | null;
@@ -163,6 +165,7 @@ export interface IProjectUpdateRequest {
   studio_name?: string;
   title: string;
   type: TProjectType;
+  weight?: number;
   description?: string | null;
   parent_id?: string | null;
   res_id?: string;

+ 1 - 0
dashboard-v4/dashboard/src/components/task/TaskBuilderChapter.tsx

@@ -263,6 +263,7 @@ const TaskBuilderChapter = ({
                     id: item.paragraph.toString(),
                     title: id === 0 && title ? title : item.text ?? "",
                     type: "instance",
+                    weight: item.chapter_strlen,
                     parent_id: item.parent.toString(),
                     res_id: `${item.book}-${item.paragraph}`,
                   };

+ 7 - 1
dashboard-v4/dashboard/src/components/task/TaskTable.tsx

@@ -98,7 +98,12 @@ const TaskTable = ({ tasks }: IWidget) => {
           {tasksTitle?.map((row, level) => {
             return (
               <tr>
-                {level === 0 ? <th rowSpan={2}>project</th> : undefined}
+                {level === 0 ? (
+                  <>
+                    <th rowSpan={2}>project</th>
+                    <th>weight</th>
+                  </>
+                ) : undefined}
                 {row.map((task, index) => {
                   return (
                     <th
@@ -118,6 +123,7 @@ const TaskTable = ({ tasks }: IWidget) => {
           {projects?.map((row, index) => (
             <tr key={index}>
               <td>{row.title}</td>
+              <td>{row.weight}</td>
               {dataHeading?.map((task, id) => {
                 const taskData = tasks?.find(
                   (value: ITaskData) =>