Webdar 1.0.0
Web user interface to libdar
html_form_overwrite_action.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef HTML_FORM_OVERWRITE_ACTION_HPP
25#define HTML_FORM_OVERWRITE_ACTION_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35
36 // webdar headers
37#include "html_overwrite_action.hpp"
38#include "html_div.hpp"
39#include "html_form_select.hpp"
40#include "html_form_fieldset.hpp"
41#include "actor.hpp"
42#include "html_form_overwrite_constant_action.hpp"
43#include "html_form_overwrite_chain_action.hpp"
44#include "jsoner.hpp"
45#include "events.hpp"
46
47 // cannot include header file as this one includes us, making a dependency loop
49
51
57
58
60 public actor,
61 public jsoner,
62 public events
63{
64public:
65
66 // events
67
68 static const std::string changed;
69
70 // actions type
71
72 static constexpr const char* action_type_const = "constant";
73 static constexpr const char* action_type_condition = "condition";
74 static constexpr const char* action_type_chain = "chain";
75
76 html_form_overwrite_action(const std::string & label);
79 html_form_overwrite_action & operator = (const html_form_overwrite_action & ref) = delete;
80 html_form_overwrite_action & operator = (html_form_overwrite_action && ref) noexcept = delete;
82
84
86 void set_action_type(const std::string & acttype) { action_type.set_selected_id(acttype); };
87
90
93
96
98 virtual std::unique_ptr<libdar::crit_action> get_overwriting_action() const override;
99
101 virtual void load_json(const json & source) override;
102
104 virtual json save_json() const override;
105
107 virtual void clear_json() override;
108
110 virtual void on_event(const std::string & event_name) override;
111
114
115protected:
116
118 virtual std::string inherited_get_body_part(const chemin & path,
119 const request & req) override;
120
121private:
122 static constexpr const char* act_changed = "action changed";
123
124 static constexpr const unsigned int format_version = 1;
125 static constexpr const char* myclass_id = "html_form_overwrite_action";
126
127 static constexpr const char* jlabel_type = "type";
128 static constexpr const char* jlabel_value = "value";
129
130 bool need_conditional_action;
131
132 // we use pointers for here
133 // to avoid cyclic dependency between html_form_overwrite_action
134 // and html_form_conditional_action
135 std::unique_ptr<html_overwrite_action> conditional_action;
136
138 html_form_select action_type;
141
142 void make_conditional_action();
143 void set_visible();
144};
145
146#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class chemin definition
Definition: chemin.hpp:51
class events
Definition: events.hpp:52
class html_form_fieldset implements HTML fieldset feature
Definition: html_form_fieldset.hpp:51
html component to be adopted by an html_form class
Definition: html_form_overwrite_action.hpp:63
void set_to_webdar_defaults()
set the object to webdar defaults
Definition: html_form_overwrite_action.cpp:246
html_form_overwrite_chain_action & get_action_when_type_chain()
get access to object storing chain action
Definition: html_form_overwrite_action.hpp:92
virtual void clear_json() override
inherited from jsoner
Definition: html_form_overwrite_action.cpp:208
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: html_form_overwrite_action.cpp:222
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder from html_overwrite_action
Definition: html_form_overwrite_action.cpp:253
virtual std::unique_ptr< libdar::crit_action > get_overwriting_action() const override
obtain the crit_action object for libdar option
Definition: html_form_overwrite_action.cpp:99
virtual json save_json() const override
inherited from jsoner
Definition: html_form_overwrite_action.cpp:177
html_form_overwrite_conditional_action & get_action_when_type_condition()
get access to object storing conditional action
Definition: html_form_overwrite_action.cpp:83
html_form_overwrite_constant_action & get_action_when_type_const()
get access to object storing constant action
Definition: html_form_overwrite_action.hpp:89
virtual void load_json(const json &source) override
inherited from jsoner
Definition: html_form_overwrite_action.cpp:126
void set_action_type(const std::string &acttype)
programmatically define the action type
Definition: html_form_overwrite_action.hpp:86
html component to be adopted by an html_form that implements a chain of actions for overwriting polic...
Definition: html_form_overwrite_chain_action.hpp:60
html component to be adopted by an html_form that implements conditional actions for overwriting poli...
Definition: html_form_overwrite_conditional_action.hpp:53
html component to be adopted by an html_form that implements constant actions for overwriting policie...
Definition: html_form_overwrite_constant_action.hpp:51
void set_selected_id(const std::string &id)
set the radio buttons to the item id given in argument
Definition: html_form_radio.cpp:89
class html_form_select implements HTML input of type "select"
Definition: html_form_select.hpp:53
html component used for constant actions in overwriting policies
Definition: html_overwrite_action.hpp:48
class jsoner
Definition: jsoner.hpp:73
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines the event class
defines jsoner class and class exception_json