Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rjs_json_form
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
rjs_json_form
Commits
634dda81
Commit
634dda81
authored
Feb 22, 2019
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notifyChange() now send action, scope and path changed subgadget
parent
a9ac5818
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
31 deletions
+75
-31
jsonform/gadget_json_generated_form_child.js
jsonform/gadget_json_generated_form_child.js
+75
-31
No files found.
jsonform/gadget_json_generated_form_child.js
View file @
634dda81
...
...
@@ -687,8 +687,13 @@
gadget
.
props
.
add_buttons
.
push
({
element
:
input
,
event
:
function
()
{
var
notify
=
{
action
:
"
add
"
};
return
event
(
schema_alternatives
[
0
].
value
)
.
push
(
function
()
{
.
push
(
function
(
v
)
{
notify
.
scope
=
v
.
scope
;
notify
.
path
=
v
.
path
;
if
(
rerender
)
{
return
rerender
(
undefined
,
schema_alternatives
);
}
...
...
@@ -700,9 +705,7 @@
}
else
{
input
.
removeAttribute
(
"
style
"
);
}
// XXX need path argument
// absent in current context
return
gadget
.
rootNotifyChange
();
return
gadget
.
rootNotifyChange
(
notify
);
});
},
rerender
:
function
()
{
...
...
@@ -732,8 +735,23 @@
});
}
function
get_scope_path_from_element
(
gadget
,
element
)
{
var
scope
=
element
.
getAttribute
(
"
data-gadget-scope
"
);
return
gadget
.
getDeclaredGadget
(
scope
)
.
push
(
function
(
g
)
{
return
g
.
getJsonPath
();
})
.
push
(
function
(
path
)
{
return
{
scope
:
scope
,
path
:
path
};
});
}
function
render_array
(
gadget
,
schema
,
json_document
,
div_input
,
path
,
schema_path
)
{
var
input
,
array_path
,
is_items_arr
=
schema
.
items
instanceof
Array
,
minItems
=
schema
.
minItems
||
0
;
if
(
json_document
instanceof
Array
&&
...
...
@@ -741,10 +759,36 @@
div_input
.
setAttribute
(
"
data-json-empty-array
"
,
"
true
"
);
}
function
current_array_length
()
{
var
array
=
div_input
.
querySelectorAll
(
"
div[data-gadget-parent-scope='
"
+
gadget
.
element
.
getAttribute
(
"
data-gadget-scope
"
)
+
"
']
"
);
return
array
.
length
;
}
function
add_item_form
(
id
,
required
)
{
return
function
(
value
)
{
return
gadget
.
expandSchema
(
schema
.
items
,
schema_path
+
'
/items
'
,
array_path
+
id
,
required
)
.
push
(
function
(
s_arr
)
{
return
addSubForm
({
gadget
:
gadget
,
parent_type
:
'
array
'
,
parent_path
:
path
,
type
:
value
&&
value
.
schema
.
type
,
selected_schema
:
value
,
schema_arr
:
s_arr
,
required
:
required
});
});
};
}
function
element_append
(
child
)
{
if
(
child
)
{
input
.
parentNode
.
insertBefore
(
child
,
input
);
div_input
.
removeAttribute
(
"
data-json-empty-array
"
);
return
get_scope_path_from_element
(
gadget
,
child
);
}
}
...
...
@@ -759,6 +803,7 @@
// input = render_textarea(schema, default_value, "array");
return
gadget
.
getJsonPath
(
path
)
.
push
(
function
(
p
)
{
array_path
=
p
;
return
RSVP
.
all
([
expandItems
(
gadget
,
schema
.
items
,
schema_path
+
'
/items
'
,
p
,
minItems
),
gadget
.
expandSchema
(
schema
.
additionalItems
,
schema_path
+
'
/additionalItems
'
,
p
,
false
)
...
...
@@ -842,17 +887,9 @@
}));
}
else
{
if
(
minItems
>
len
&&
checkSchemaArrOneChoise
(
schema_arr
))
{
for
(
i
=
0
;
i
<
(
minItems
-
len
)
;
i
+=
1
)
{
for
(
i
=
len
;
i
<
minItems
;
i
+=
1
)
{
queue
.
push
(
addSubForm
.
bind
(
gadget
,
{
gadget
:
gadget
,
parent_type
:
'
array
'
,
parent_path
:
path
,
schema_arr
:
schema_arr
,
required
:
true
})
)
.
push
(
add_item_form
(
i
,
true
))
.
push
(
div_append
);
}
}
...
...
@@ -860,14 +897,7 @@
queue
.
push
(
render_schema_selector
.
bind
(
gadget
,
gadget
,
"
add item to array
"
,
schema_arr
,
function
(
value
)
{
return
addSubForm
({
gadget
:
gadget
,
parent_type
:
'
array
'
,
parent_path
:
path
,
type
:
value
.
type
,
selected_schema
:
value
,
schema_arr
:
schema_arr
})
return
add_item_form
(
current_array_length
(),
false
)(
value
)
.
push
(
element_append
);
}));
}
...
...
@@ -1354,6 +1384,7 @@
if
(
child
)
{
// insert additionalProperty before selector
selector
.
element
.
parentNode
.
insertBefore
(
child
,
selector
.
element
);
return
get_scope_path_from_element
(
g
,
child
);
}
}
...
...
@@ -1756,15 +1787,16 @@
g
.
options
=
{};
})
.
declareAcquiredMethod
(
"
rNotifyChange
"
,
"
rootNotifyChange
"
)
.
declareMethod
(
"
rootNotifyChange
"
,
function
(
path
)
{
.
declareMethod
(
"
rootNotifyChange
"
,
function
(
v
)
{
var
g
=
this
;
this
.
props
.
needValidate
=
true
;
return
g
.
getJsonPath
(
path
)
return
g
.
getJsonPath
(
v
.
path
)
.
push
(
function
(
p
)
{
return
g
.
rNotifyChange
({
scope
:
g
.
element
.
getAttribute
(
"
data-gadget-scope
"
),
rel_path
:
path
,
path
:
p
scope
:
v
.
scope
||
g
.
element
.
getAttribute
(
"
data-gadget-scope
"
),
rel_path
:
v
.
path
,
path
:
p
,
action
:
v
.
action
});
});
})
...
...
@@ -1784,7 +1816,10 @@
return
RSVP
.
all
(
tasks
);
})
.
push
(
function
()
{
return
g
.
deleteChildren
();
return
g
.
getJsonPath
();
})
.
push
(
function
(
path
)
{
return
g
.
deleteChildren
(
path
);
});
})
.
declareAcquiredMethod
(
"
deleteChildren
"
,
"
deleteChildren
"
)
...
...
@@ -1792,6 +1827,7 @@
var
g
=
this
,
key
,
i
,
path
=
arr
[
0
],
button_list
=
this
.
props
.
add_buttons
,
objects
=
this
.
props
.
objects
,
element
=
getSubGadgetElement
(
g
,
scope
),
...
...
@@ -1818,7 +1854,11 @@
return
RSVP
.
all
(
tasks
);
})
.
push
(
function
()
{
return
g
.
rootNotifyChange
();
return
g
.
rootNotifyChange
({
scope
:
scope
,
path
:
path
,
action
:
"
delete
"
});
})
.
push
(
function
()
{
// remove gadget at end otherwise
...
...
@@ -1981,7 +2021,9 @@
if
(
event_object
&&
evt
.
type
===
"
change
"
)
{
return
event_object
.
event
();
}
return
g
.
rootNotifyChange
(
evt
.
target
.
name
);
return
g
.
rootNotifyChange
({
path
:
evt
.
target
.
name
});
})
.
declareMethod
(
'
renderForm
'
,
function
(
options
)
{
var
g
=
this
,
...
...
@@ -2238,7 +2280,9 @@
}
}
if
(
changed
)
{
return
gadget
.
rootNotifyChange
(
input
.
name
);
return
gadget
.
rootNotifyChange
({
path
:
input
.
name
});
}
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment