CCM NG: Progress on the PageModelsEditor
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5607 8810af33-2d31-482b-a856-94f89814c4df
parent
6e09b7ff61
commit
e77ce5ecc3
|
|
@ -327,8 +327,14 @@ public class Components {
|
||||||
throw new WebApplicationException(ex);
|
throw new WebApplicationException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
objectBuilder.add(propertyDescriptor.getName(),
|
final String valueStr;
|
||||||
value.toString());
|
if (value == null) {
|
||||||
|
valueStr = "";
|
||||||
|
} else {
|
||||||
|
valueStr = value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
objectBuilder.add(propertyDescriptor.getName(), valueStr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,11 @@
|
||||||
package org.libreccm.pagemodel.rs;
|
package org.libreccm.pagemodel.rs;
|
||||||
|
|
||||||
import com.arsdigita.kernel.KernelConfig;
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
import org.libreccm.configuration.ConfigurationManager;
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
import org.libreccm.core.CoreConstants;
|
import org.libreccm.core.CoreConstants;
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.libreccm.pagemodel.ComponentModel;
|
||||||
import org.libreccm.pagemodel.ContainerModel;
|
import org.libreccm.pagemodel.ContainerModel;
|
||||||
import org.libreccm.pagemodel.PageModel;
|
import org.libreccm.pagemodel.PageModel;
|
||||||
import org.libreccm.pagemodel.PageModelManager;
|
import org.libreccm.pagemodel.PageModelManager;
|
||||||
|
|
@ -47,6 +49,7 @@ import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
|
||||||
|
|
@ -568,7 +568,8 @@ class ContainerListComponent
|
||||||
container={container}
|
container={container}
|
||||||
deleteContainer={this.deleteContainer}
|
deleteContainer={this.deleteContainer}
|
||||||
dispatcherPrefix={this.props.dispatcherPrefix}
|
dispatcherPrefix={this.props.dispatcherPrefix}
|
||||||
errorMsg="" />)
|
errorMsg=""
|
||||||
|
pageModelName={this.props.pageModelName} />)
|
||||||
// <li>
|
// <li>
|
||||||
// <span>{container.key}</span>
|
// <span>{container.key}</span>
|
||||||
// <button
|
// <button
|
||||||
|
|
@ -761,19 +762,39 @@ interface ContainerModelComponentProps {
|
||||||
deleteContainer: (key: string) => void;
|
deleteContainer: (key: string) => void;
|
||||||
dispatcherPrefix: string;
|
dispatcherPrefix: string;
|
||||||
errorMsg: string;
|
errorMsg: string;
|
||||||
|
pageModelName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ContainerModelComponentState {
|
||||||
|
|
||||||
|
components: ComponentModel[];
|
||||||
|
errorMessages: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContainerModelComponent
|
class ContainerModelComponent
|
||||||
extends React.Component<ContainerModelComponentProps, {}> {
|
extends React.Component<ContainerModelComponentProps,
|
||||||
|
ContainerModelComponentState> {
|
||||||
|
|
||||||
constructor(props: ContainerModelComponentProps) {
|
constructor(props: ContainerModelComponentProps) {
|
||||||
|
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
|
||||||
|
components: [],
|
||||||
|
errorMessages: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public componentDidMount() {
|
||||||
|
|
||||||
|
this.fetchComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): React.ReactNode {
|
public render(): React.ReactNode {
|
||||||
|
|
||||||
return <li>
|
return <li>
|
||||||
|
<div className="container-header">
|
||||||
<span>{this.props.container.key}</span>
|
<span>{this.props.container.key}</span>
|
||||||
<button
|
<button
|
||||||
onClick={(event) => this.deleteContainer(
|
onClick={(event) => this.deleteContainer(
|
||||||
|
|
@ -782,7 +803,81 @@ class ContainerModelComponent
|
||||||
<span className="fa fa-minus-circle"></span>
|
<span className="fa fa-minus-circle"></span>
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="components-list">
|
||||||
|
<ul>
|
||||||
|
{this.state.components.map((component: ComponentModel) =>
|
||||||
|
<li>
|
||||||
|
{component.key}
|
||||||
</li>
|
</li>
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
|
||||||
|
private fetchComponents(): void {
|
||||||
|
|
||||||
|
const componentsUrl = `${this.props.dispatcherPrefix}`
|
||||||
|
+ `/page-models/${this.props.ccmApplication}`
|
||||||
|
+ `/${this.props.pageModelName}`
|
||||||
|
+ `/containers/${this.props.container.key}`
|
||||||
|
+ `/components`;
|
||||||
|
|
||||||
|
const init: RequestInit = {
|
||||||
|
credentials: "same-origin",
|
||||||
|
method: "GET",
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch(componentsUrl, init)
|
||||||
|
.then((response) => {
|
||||||
|
if (response.ok) {
|
||||||
|
|
||||||
|
response
|
||||||
|
.json()
|
||||||
|
.then((components) => {
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
...this.state,
|
||||||
|
components,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
const errorMessages: string[] = this
|
||||||
|
.state.errorMessages;
|
||||||
|
errorMessages.push(`Failed to retrieve PageModels ` +
|
||||||
|
`from ${componentsUrl}: ${error.message}`);
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
...this.state,
|
||||||
|
errorMessages,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const errorMessages: string[] = this
|
||||||
|
.state.errorMessages;
|
||||||
|
errorMessages.push(`Failed to retrieve PageModels from `
|
||||||
|
+ `\"${componentsUrl}\": HTTP Status Code: `
|
||||||
|
+ `${response.status}; `
|
||||||
|
+ `message: ${response.statusText}`);
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
...this.state,
|
||||||
|
errorMessages,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
const errorMessages: string[] = this
|
||||||
|
.state.errorMessages;
|
||||||
|
errorMessages.push(`Failed to retrieve PageModels ` +
|
||||||
|
`from ${componentsUrl}: ${error.message}`);
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
...this.state,
|
||||||
|
errorMessages,
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private deleteContainer(
|
private deleteContainer(
|
||||||
|
|
@ -819,7 +914,6 @@ interface ComponentInfo {
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class PageModelEditor
|
class PageModelEditor
|
||||||
extends React.Component<{}, PageModelEditorState> {
|
extends React.Component<{}, PageModelEditorState> {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue