From ac78e34d75557a5378cf16270bffb9923b843ccd Mon Sep 17 00:00:00 2001
From: ko_oler <kooler89@gmail.com>
Date: Mon, 18 Sep 2023 15:58:43 +0300
Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B2?=
 =?UTF-8?q?=20action.go?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 pkg/extension/action.go | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/pkg/extension/action.go b/pkg/extension/action.go
index 3f090dff..3230219c 100644
--- a/pkg/extension/action.go
+++ b/pkg/extension/action.go
@@ -18,6 +18,8 @@ type (
 	ActionRequest  = pb.ActionRequest
 	ActionResponse = pb.ActionResponse
 
+	ActionTarget = pb.Target
+
 	//ActionRequest struct {
 	//	Extension    string
 	//	Action       string
@@ -61,6 +63,8 @@ const (
 type Action struct {
 	Extension        string                  `mapstructure:"extension,omitempty"`   // Расширение
 	Action           string                  `mapstructure:"action,omitempty"`      // Идентификатор действия
+	Target           ActionTarget            `mapstructure:"target,omitempty"`      // Как должен отображаться результат действия
+	Parent           string                  `mapstructure:"parent,omitempty"`      // Идентификатор родительского действия (для отображения в меню)
 	Name             string                  `mapstructure:"name,omitempty"`        // Название действия для отображения в интерфейсе (пункт меню, кнопка).
 	Description      string                  `mapstructure:"description,omitempty"` // Описание действия для отображения в интерфейсе
 	Icon             string                  `mapstructure:"icon,omitempty"`        // Название иконки для отображения действия в интерфейсе
@@ -71,14 +75,17 @@ type Action struct {
 	Refs             []*references.Reference `mapstructure:"refs,omitempty"`        // Ссылки на записи используемые для выполнения действия (назначение ссылок зависит от действия и расширения)
 	ParamsCollection string                  `mapstructure:"params_collection,omitempty"`
 	Request          *ActionRequest          `mapstructure:"request,omitempty"`           // Параметры запроса (используется в случае `ActionResponse.next`)
-	NavigationAction bool                    `mapstructure:"navigation_action,omitempty"` // Флаг указывающий что действие переносить пользователя в другую часть интерфейса, а не отправляет запрос на сервер
+	NavigationAction bool                    `mapstructure:"navigation_action,omitempty"` // Флаг указывающий, что действие переносить пользователя в другую часть интерфейса, а не отправляет запрос на сервер
 	NavigationRoute  string                  `mapstructure:"navigation_route,omitempty"`
+	Autorun          bool                    `mapstructure:"autorun,omitempty"` // Параметр указывающий, что действие выполняется автоматически
+	Confirm          bool                    `mapstructure:"confirm,omitempty"` // Параметр указывающий, что действие требует подтверждения пользователя
 }
 
 func ActionToMap(action *Action) map[string]interface{} {
 	res := make(map[string]interface{})
-	mapstructure.Decode(action, &res)
+	_ = mapstructure.Decode(action, &res)
 	res["kind"] = int64(action.Kind.Number())
+	res["target"] = int64(action.Target.Number())
 	return res
 }
 
@@ -172,6 +179,8 @@ func ActionFromPB(a *pb.Action) *Action {
 	return &Action{
 		Extension:        a.Extension,
 		Action:           a.Action,
+		Target:           a.Target,
+		Parent:           a.Parent,
 		Name:             a.Name,
 		Description:      a.Description,
 		Icon:             a.Icon,
@@ -185,6 +194,8 @@ func ActionFromPB(a *pb.Action) *Action {
 		//Request:          ActionRequestFromPB(a.Request),
 		NavigationAction: a.NavigationAction,
 		NavigationRoute:  a.NavigationRoute,
+		Autorun:          a.Autorun,
+		Confirm:          a.Confirm,
 	}
 }
 
-- 
GitLab