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
Jérome Perrin
rjs_json_form
Commits
f36630f9
Commit
f36630f9
authored
Sep 27, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve gadget_complex_demo_form.js
parent
ea3510f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
38 deletions
+91
-38
demo/gadget_complex_demo_form.js
demo/gadget_complex_demo_form.js
+91
-38
No files found.
demo/gadget_complex_demo_form.js
View file @
f36630f9
...
@@ -3,33 +3,78 @@
...
@@ -3,33 +3,78 @@
(
function
(
window
,
rJS
,
jIO
)
{
(
function
(
window
,
rJS
,
jIO
)
{
"
use strict
"
;
"
use strict
"
;
function
transform_olap_dimensions
(
g
,
dimensions
)
{
function
transform_olap_dimensions
(
g
,
dimensions
)
{
var
dimension
;
var
dimension
,
hierarchies
,
i
;
for
(
dimension
in
dimensions
)
{
for
(
dimension
in
dimensions
)
{
if
(
dimensions
.
hasOwnProperty
(
dimension
))
{
if
(
dimensions
.
hasOwnProperty
(
dimension
))
{
hierarchies
=
dimensions
[
dimension
];
for
(
i
=
0
;
i
<
hierarchies
.
length
;
i
+=
1
)
{
hierarchies
[
i
].
dimension
=
dimension
;
g
.
props
.
hierarchies
[
hierarchies
[
i
].
const
]
=
hierarchies
[
i
];
}
}
}
}
}
}
}
function
generate_schema
()
{
function
generate_schema
(
g
,
axis
,
title
)
{
console
.
log
(
"
render
"
+
axis
);
var
used_dimensions
=
[],
h
,
hierarchies
=
[],
i
;
if
(
!
g
.
props
.
axes
.
hasOwnProperty
(
axis
))
{
g
.
props
.
axes
[
axis
]
=
[];
}
for
(
i
in
g
.
props
.
axes
)
{
if
(
g
.
props
.
axes
.
hasOwnProperty
(
i
)
&&
i
!==
axis
)
{
used_dimensions
=
used_dimensions
.
concat
(
g
.
props
.
axes
[
i
]);
}
}
for
(
i
in
g
.
props
.
hierarchies
)
{
if
(
g
.
props
.
hierarchies
.
hasOwnProperty
(
i
))
{
h
=
g
.
props
.
hierarchies
[
i
];
if
(
used_dimensions
.
indexOf
(
h
.
dimension
)
<
0
)
{
hierarchies
.
push
(
h
);
}
}
}
return
{
title
:
title
,
type
:
"
array
"
,
uniqueItems
:
true
,
items
:
{
oneOf
:
hierarchies
}
};
}
}
function
render_form
(
gadget
,
scope
,
schema
)
{
function
render_form
(
gadget
,
scope
,
schema
,
value
)
{
return
gadget
.
getDeclaredGadget
(
scope
)
return
gadget
.
getDeclaredGadget
(
scope
)
.
push
(
function
(
g
)
{
.
push
(
function
(
g
)
{
return
g
.
render
({
return
g
.
render
({
schema
:
schema
schema
:
schema
,
value
:
value
});
});
});
});
}
}
function
updateTextContent
(
g
)
{
document
.
getElementById
(
"
json_document_content
"
).
textContent
=
JSON
.
stringify
({
columns
:
JSON
.
parse
(
g
.
state
.
columns
),
rows
:
JSON
.
parse
(
g
.
state
.
rows
)
},
null
,
2
);
}
rJS
(
window
)
rJS
(
window
)
.
ready
(
function
(
g
)
{
.
ready
(
function
(
g
)
{
g
.
props
=
{};
g
.
props
=
{};
g
.
props
.
dimensions
=
{
g
.
props
.
hierarchies
=
{};
g
.
props
.
axes
=
[];
transform_olap_dimensions
(
g
,
{
"
Time
"
:
[
"
Time
"
:
[
{
title
:
'
Year
'
,
const
:
'
[Time].[Time].[Year]
'
},
{
title
:
'
Year
'
,
const
:
'
[Time].[Time].[Year]
'
},
{
title
:
'
Quarter
'
,
const
:
'
[Time].[Time].[Quarter]
'
}
{
title
:
'
Quarter
'
,
const
:
'
[Time].[Time].[Quarter]
'
}
...
@@ -39,31 +84,19 @@
...
@@ -39,31 +84,19 @@
{
title
:
'
Product Department
'
,
const
:
'
[Product].[Products].[Product Department]
'
},
{
title
:
'
Product Department
'
,
const
:
'
[Product].[Products].[Product Department]
'
},
{
title
:
'
Product Category
'
,
const
:
'
[Product].[Products].[Product Category]
'
}
{
title
:
'
Product Category
'
,
const
:
'
[Product].[Products].[Product Category]
'
}
]
]
});
g
.
state
=
{
columns
:
'
[]
'
,
rows
:
'
[]
'
};
};
g
.
props
.
dimensions
=
[
updateTextContent
(
g
);
{
title
:
'
Year
'
,
const
:
'
[Time].[Time].[Year]
'
},
return
new
RSVP
.
Queue
()
{
title
:
'
Quarter
'
,
const
:
'
[Time].[Time].[Quarter]
'
},
.
push
(
function
()
{
{
title
:
'
Product Family
'
,
const
:
'
[Product].[Products].[Product Family]
'
},
return
RSVP
.
all
([
{
title
:
'
Product Department
'
,
const
:
'
[Product].[Products].[Product Department]
'
},
render_form
(
g
,
"
columns
"
,
generate_schema
(
g
,
"
columns
"
,
"
columns:
"
),
[]),
{
title
:
'
Product Category
'
,
const
:
'
[Product].[Products].[Product Category]
'
}
render_form
(
g
,
"
rows
"
,
generate_schema
(
g
,
"
rows
"
,
"
rows:
"
),
[])
];
]);
});
return
RSVP
.
all
([
render_form
(
g
,
"
columns
"
,
{
title
:
"
columns:
"
,
type
:
"
array
"
,
items
:
{
oneOf
:
g
.
props
.
dimensions
}
}),
render_form
(
g
,
"
rows
"
,
{
title
:
"
rows:
"
,
type
:
"
array
"
,
items
:
{
oneOf
:
g
.
props
.
dimensions
}
})
]);
})
})
.
allowPublicAcquisition
(
"
notifyValid
"
,
function
(
arr
,
scope
)
{
.
allowPublicAcquisition
(
"
notifyValid
"
,
function
(
arr
,
scope
)
{
})
})
...
@@ -78,15 +111,35 @@
...
@@ -78,15 +111,35 @@
})
})
.
push
(
function
(
ret
)
{
.
push
(
function
(
ret
)
{
var
z
=
{};
var
z
=
{};
z
[
scope
]
=
ret
;
z
[
scope
]
=
JSON
.
stringify
(
ret
)
;
return
gadget
.
changeState
(
z
);
return
gadget
.
changeState
(
z
);
});
});
}
}
})
})
.
onStateChange
(
function
()
{
.
onStateChange
(
function
(
modification_dict
)
{
var
g
=
this
;
var
g
=
this
,
document
.
getElementById
(
"
json_document_content
"
).
textContent
=
scope
,
JSON
.
stringify
(
g
.
state
,
null
,
2
);
mod
,
i
,
dimension
,
used_dimensions
;
for
(
scope
in
modification_dict
)
{
if
(
modification_dict
.
hasOwnProperty
(
scope
))
{
used_dimensions
=
[];
mod
=
JSON
.
parse
(
modification_dict
[
scope
]);
for
(
i
=
0
;
i
<
mod
.
length
;
i
+=
1
)
{
dimension
=
g
.
props
.
hierarchies
[
mod
[
i
]].
dimension
;
used_dimensions
.
push
(
dimension
);
}
g
.
props
.
axes
[
scope
]
=
used_dimensions
;
}
}
updateTextContent
(
g
);
// if return used here then rendering cancel
RSVP
.
all
([
render_form
(
g
,
"
columns
"
,
generate_schema
(
g
,
"
columns
"
,
"
columns:
"
)),
render_form
(
g
,
"
rows
"
,
generate_schema
(
g
,
"
rows
"
,
"
rows:
"
))
]);
});
});
}(
window
,
rJS
,
jIO
));
}(
window
,
rJS
,
jIO
));
\ No newline at end of file
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