Skip to content

Commit

Permalink
The dropdown entry for "Select the project type variant" (Please sele…
Browse files Browse the repository at this point in the history
…ct) is not grayed out anymore

prevent selecting documentation tab if not all parameters are set
fixed problem where an empty id of "Externe Kopiervorlage" crashed the site
save product templates inside the zip file in folder structure of disciplines
  • Loading branch information
Bock4Soft committed Nov 27, 2023
1 parent 881201d commit 94d5ee5
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 59 deletions.
8 changes: 8 additions & 0 deletions client/public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,11 @@ ul.sideMenu > li > ul > li > ul > li > div {
/* margin-top: 24px;*/
/*}*/

/* Otherwise, the drop-down lists look as if they are disabled */
.ant-select-selector > .ant-select-selection-placeholder {
color: rgba(0, 0, 0, 0.88);
}

.disable-link{
pointer-events: none;
}
87 changes: 49 additions & 38 deletions client/src/components/header/SiteHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,6 @@ import { LinkWithQuery } from '../LinkWithQuery';

const { Header } = Layout;

const items: MenuProps['items'] = [
{
label: <LinkWithQuery to="/tailoring">Tailoring</LinkWithQuery>,
// <a href="#/tailoring">Tailoring</a>,
key: 'tailoring',
icon: <ScissorOutlined />,
},
{
label: <LinkWithQuery to="/documentation">Dokumentation</LinkWithQuery>,
// label: <a href="#/documentation">Dokumentation</a>,
key: 'dokumentation',
icon: <FileTextOutlined />,
},
{
label: <LinkWithQuery to="/productTemplates">Produktvorlagen</LinkWithQuery>,
// label: <a href="#/productTemplates">Produktvorlagen</a>,
key: 'productTemplates',
icon: <BookOutlined />,
},
{
label: (
<LinkWithQuery to="/info">Info</LinkWithQuery>
// <LinkWithQuery href="#/" children={undefined} to={undefined}>
// Home
// </LinkWithQuery>
),
key: 'info',
icon: <HomeOutlined />,
},
];

// <Menu.Item key="1">
// <HomeOutlined />
// <Link to="/"> Home</Link>
Expand All @@ -59,13 +28,55 @@ const items: MenuProps['items'] = [
export const SiteHeader = (props: any) => {
const { tailoringParameter } = useTailoring();

// const navigate = useNavigate();

// const handleMenuClick = ({ key: string }) => {
// if (key) {
// navigate(key);
// }
// };
const items: MenuProps['items'] = [
{
label: <LinkWithQuery to="/tailoring">Tailoring</LinkWithQuery>,
key: 'tailoring',
icon: <ScissorOutlined />,
},
{
label: (
<LinkWithQuery
to="/documentation"
class={!tailoringParameter.projectTypeId ? 'disable-link' : ''}
disabled={!tailoringParameter.projectTypeId}
>
Dokumentation
</LinkWithQuery>
),
key: 'dokumentation',
icon: <FileTextOutlined />,
disabled: !tailoringParameter.projectTypeId,
},
{
label: (
<LinkWithQuery
to="/productTemplates"
class={!tailoringParameter.projectTypeId ? 'disable-link' : ''}
disabled={!tailoringParameter.projectTypeId}
>
Produktvorlagen
</LinkWithQuery>
),
key: 'productTemplates',
icon: <BookOutlined />,
disabled: !tailoringParameter.projectTypeId,
},
{
label: (
<LinkWithQuery
to="/info"
class={!tailoringParameter.modelVariantId ? 'disable-link' : ''}
disabled={!tailoringParameter.modelVariantId}
>
Info
</LinkWithQuery>
),
key: 'info',
icon: <HomeOutlined />,
disabled: !tailoringParameter.modelVariantId,
},
];

const { error, image } = useImage(tailoringParameter.modelVariantId + '/ALLG-Logo-Farbe.gif');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
fixLinksInText,
flatten,
getJsonDataFromXml,
getMenuItemByAttributeValue,
getSearchStringFromHash,
replaceUrlInText,
} from '../../../../shares/utils';
Expand Down Expand Up @@ -1949,10 +1950,13 @@ export function Content() {
);
};

const disciplineMenuEntry = getMenuItemByAttributeValue(navigationData, 'key', disciplineId);
const headerLabel = disciplineMenuEntry ? disciplineMenuEntry.label : '';

return {
id: 'externalTemplateContent', //jsonDataFromXml.attributes.id,
// menuEntryId: jsonDataFromXml.attributes.id,
header: 'Disziplin', //jsonDataFromXml.attributes.name,
header: headerLabel, //jsonDataFromXml.attributes.name,
descriptionText: '',
tableEntries: [],
dataSource: data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,16 +794,18 @@ export function Navigation() {
jsonDataFromXml.getElementsByTagName('ExterneKopiervorlage').map((externalMasterTemplate) => {
const productRef = externalMasterTemplate.getElementsByTagName('ProduktRef')[0];

const productToDisciplineEntryKey = productToDisciplineMap.get(productRef.attributes.id)!.key;

if (!disciplineEntriesMap.get(productToDisciplineEntryKey)) {
disciplineEntriesMap.set(productToDisciplineEntryKey, {
key: 'td_' + productToDisciplineEntryKey, // TODO: check !
parent: target,
label: productToDisciplineMap.get(productRef.attributes.id)!.title, // TODO: check !
dataType: NavTypeEnum.TEMPLATE_DISCIPLINE,
onClick: (item: any) => handleSelectedItem(item.key),
});
if (productRef.attributes.id) {
const productToDisciplineEntryKey = productToDisciplineMap.get(productRef.attributes.id)!.key;

if (!disciplineEntriesMap.get(productToDisciplineEntryKey)) {
disciplineEntriesMap.set(productToDisciplineEntryKey, {
key: 'td_' + productToDisciplineEntryKey, // TODO: check !
parent: target,
label: productToDisciplineMap.get(productRef.attributes.id)!.title, // TODO: check !
dataType: NavTypeEnum.TEMPLATE_DISCIPLINE,
onClick: (item: any) => handleSelectedItem(item.key),
});
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function SubmitArea() {
if (product) {
productOfProjectMap.set(product.product.id, {
productName: product.product.title,
disciplineName: product.discipline.title,
responsible: '',
participants: [],
chapters: getChaptersData(product.topics),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package online.projektassistent.server.model;

import java.util.List;
import java.util.Objects;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Objects;

@SuppressWarnings("unused")
public class ProductOfProject {

@NotBlank(message = "productName is mandatory")
private String productName;

private String disciplineName;

@NotBlank(message = "responsible is mandatory")
private String responsible;

Expand All @@ -24,6 +25,10 @@ public String getProductName() {
return productName;
}

public String getDisciplineName() {
return disciplineName;
}

public String getResponsible() {
return responsible;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package online.projektassistent.server.model;

import java.util.List;
import java.util.Objects;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Objects;

@SuppressWarnings("unused")
public class SingleProduct {

@NotBlank(message = "productName is mandatory")
private String productName;

private String disciplineName;

@NotBlank(message = "responsible is mandatory")
private String responsible;

Expand All @@ -26,6 +27,10 @@ public String getProductName() {
return productName;
}

public String getDisciplineName() {
return disciplineName;
}

public String getResponsible() {
return responsible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public class ProductBuilder implements Placeholders {
private final Logger logger = LoggerFactory.getLogger(ProductBuilder.class);

/**
* Creates a single product and returns a byte array in doxc format
* Creates a single product and returns a byte array in docx format
*
* @param singleProduct container for all parameters
* @return bytes in doxc format
* @return bytes in docx format
*/
public byte[] createSingleProduct(SingleProduct singleProduct) throws IOException {
Map<String, String> dataParams = new HashMap<>();
Expand Down Expand Up @@ -84,7 +84,7 @@ public Path createMultipleProducts(MultiProducts multiProducts) throws IOExcepti
}

/**
* Creates multiple doxc files in temp directory
* Creates multiple docx files in temp directory
*
* @param products list of product parameters
* @param dataParams map with project parameters
Expand All @@ -109,7 +109,13 @@ private Map<String, Path> createProductTempFiles(List<ProductOfProject> products
template.write(out);
Files.write(tempFile, out.toByteArray());
}
productsMap.put(FileUtil.sanitizeFilename(product.getProductName()) + ".docx", tempFile);

String sanitizedDirectory = product.getDisciplineName();
String sanitizedFilename = FileUtil.sanitizeFilename(product.getProductName());

String filename = sanitizedDirectory != null ? sanitizedDirectory + "/" + sanitizedFilename : sanitizedFilename;

productsMap.put(filename + ".docx", tempFile);
} catch (InvalidFormatException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 94d5ee5

Please sign in to comment.