Skip to content
Permalink
Browse files

feat(asset-bundle): header->"generate single rab" add "name" input

  • Loading branch information...
yyc-git committed May 6, 2019
1 parent 0c82898 commit 2c34074e85123b7654cd27679ac18f528cc448f8
@@ -19,24 +19,24 @@ let reducer = (action, state) =>
| Change(value) => ReasonReact.Update({...state, inputValue: value})
};

let _renderContent = ({state, send}: ReasonReact.self('a, 'b, 'c)) =>
<div className="modal-item-content">
<div className="content-field">
<div className="field-title"> {DomHelper.textEl("name")} </div>
<div className="field-content">
<input
className="input-component"
type_="text"
value={state.inputValue}
onChange={_e => send(Method.change(_e))}
/>
</div>
let _renderInput = ({state, send}: ReasonReact.self('a, 'b, 'c), inputText) =>
<div className="content-field">
<div className="field-title"> {DomHelper.textEl(inputText)} </div>
<div className="field-content">
<input
className="input-component"
type_="text"
value={state.inputValue}
onChange={_e => send(Method.change(_e))}
/>
</div>
</div>;

let render =
(
title,
inputText,
content,
(closeFunc, submitFunc),
({state, send}: ReasonReact.self('a, 'b, 'c)) as self,
) =>
@@ -46,7 +46,10 @@ let render =
{DomHelper.textEl(title)}
<img src="./public/img/close.png" onClick={_e => closeFunc()} />
</div>
{_renderContent(self)}
<div className="modal-item-content">
{_renderInput(self, inputText)}
{ReasonReact.array(content)}
</div>
<div className="modal-item-footer">
<button
className="footer-submit"
@@ -61,6 +64,8 @@ let make =
(
~closeFunc,
~title,
~inputText,
~content=[||],
~submitFunc,
~defaultValue: option(string)=?,
_children,
@@ -72,5 +77,6 @@ let make =
| Some(value) => {inputValue: value}
},
reducer,
render: _self => render(title, (closeFunc, submitFunc), _self),
render: _self =>
render(title, inputText, content, (closeFunc, submitFunc), _self),
};
@@ -317,7 +317,7 @@ module Method = {
};

let generateAndDownloadSingleRAB =
(selectTreeForGenerateSingleRAB, (editorState, engineState)) => {
(selectTreeForGenerateSingleRAB, baseName, (editorState, engineState)) => {
let (
basicMaterials,
lightMaterials,
@@ -346,38 +346,34 @@ module Method = {
engineState,
);

/* TODO feat: name should be edit */
HeaderAssetBundleUtils.downloadAB("WonderSingleRAB.rab", rab);
HeaderAssetBundleUtils.downloadAB({j|$(baseName).rab|j}, rab);
};

/* let hideGenerateSingleRABModal = send => send(HideGenerateSingleRABModal); */

let renderGenerateSingleRABModal =
(
languageType,
selectTreeForGenerateSingleRAB,
send,
(closeFunc, submitFunc),
) =>
<Modal
<SingleInputModal
title={
LanguageUtils.getHeaderLanguageDataByType(
"generate-single-rab",
languageType,
)
}
closeFunc={
() =>
/* hideGenerateSingleRABModal(send); */
closeFunc()
}
inputText="name"
defaultValue="WonderSingleRAB"
closeFunc
submitFunc={
() => {
generateAndDownloadSingleRAB(selectTreeForGenerateSingleRAB)
baseName => {
generateAndDownloadSingleRAB(
selectTreeForGenerateSingleRAB,
baseName,
)
|> StateLogicService.getStateToGetData;

/* hideGenerateSingleRABModal(send); */

submitFunc();
}
}
@@ -392,14 +388,13 @@ let component =

let reducer = (action, state) =>
switch (action) {
/* | HideGenerateSingleRABModal =>
ReasonReact.Update({...state, selectTreeForGenerateSingleRAB: None}) */
| UpdateSelectTreeForGenerateSingleRAB(selectTree) =>
ReasonReact.Update({...state, selectTreeForGenerateSingleRAB: selectTree})
};

let render =
({state, send}: ReasonReact.self('a, 'b, 'c), (closeFunc, submitFunc)) => {
Js.log("render sissssssss");
let languageType =
LanguageEditorService.unsafeGetType |> StateLogicService.getEditorState;

@@ -22,6 +22,7 @@ let render =
languageType,
)
}
inputText="name"
defaultValue="WonderSingleSAB"
closeFunc={() => closeFunc()}
submitFunc={
@@ -164,6 +164,7 @@ let render =
languageType,
)
}
inputText="name"
defaultValue="WonderPackage"
closeFunc={() => send(HideExportPackageModal)}
submitFunc={
@@ -185,6 +186,7 @@ let render =
languageType,
)
}
inputText="name"
defaultValue="WonderScene"
closeFunc={() => send(HideExportSceneModal)}
submitFunc={
@@ -2,7 +2,7 @@

exports[`Header AssetBundle test generate single rab test buildSelectTreeForGenerateSingleRAB test1 1`] = `
<article
className="wonder-modal"
className="wonder-singleInput-modal"
>
<div
className="modal-item"
@@ -19,6 +19,25 @@ exports[`Header AssetBundle test generate single rab test buildSelectTreeForGene
<div
className="modal-item-content"
>
<div
className="content-field"
>
<div
className="field-title"
>
name
</div>
<div
className="field-content"
>
<input
className="input-component"
onChange={[Function]}
type="text"
value="WonderSingleRAB"
/>
</div>
</div>
<article
className="wonder-selectTree"
>
@@ -512,7 +531,7 @@ data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQIBA

exports[`Header AssetBundle test generate single rab test buildSelectTreeForGenerateSingleRAB test2 1`] = `
<article
className="wonder-modal"
className="wonder-singleInput-modal"
>
<div
className="modal-item"
@@ -529,6 +548,25 @@ exports[`Header AssetBundle test generate single rab test buildSelectTreeForGene
<div
className="modal-item-content"
>
<div
className="content-field"
>
<div
className="field-title"
>
name
</div>
<div
className="field-content"
>
<input
className="input-component"
onChange={[Function]}
type="text"
value="WonderSingleRAB"
/>
</div>
</div>
<article
className="wonder-selectTree"
>

0 comments on commit 2c34074

Please sign in to comment.
You can’t perform that action at this time.