Skip to content

Commit

Permalink
chore(edit-content): Edit Contentlet Redesign: Create New Binary Fiel…
Browse files Browse the repository at this point in the history
…d Feature Flag fix #26219

* dev: implement New Binary Field Feature Flag

* dev: add conditional to handle empy feature flag

* dev: improve variable naming

* dev: build binary-field
  • Loading branch information
rjvelazco authored Sep 28, 2023
1 parent d0f3abe commit 40f56af
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class ConfigurationResource implements Serializable {
new String[] {"EMAIL_SYSTEM_ADDRESS", "CHARSET","CONTENT_PALETTE_HIDDEN_CONTENT_TYPES",
"FEATURE_FLAG_EXPERIMENTS", "DOTFAVORITEPAGE_FEATURE_ENABLE", "FEATURE_FLAG_TEMPLATE_BUILDER_2",
"SHOW_VIDEO_THUMBNAIL", "EXPERIMENTS_MIN_DURATION", "EXPERIMENTS_MAX_DURATION", "FEATURE_FLAG_SEO_IMPROVEMENTS",
"FEATURE_FLAG_SEO_PAGE_TOOLS", "FEATURE_FLAG_EDIT_URL_CONTENT_MAP"}));
"FEATURE_FLAG_SEO_PAGE_TOOLS", "FEATURE_FLAG_EDIT_URL_CONTENT_MAP", "FEATURE_FLAG_NEW_BINARY_FIELD"}));


private boolean isOnBlackList(final String key) {
Expand Down
2 changes: 1 addition & 1 deletion dotCMS/src/main/webapp/html/contenttype-fields.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@
</style>

<!--
Uncomment this when we are ready to use the new content fields
<%
String isNewBinaryFieldEnabled = Config.getStringProperty("FEATURE_FLAG_NEW_BINARY_FIELD");
if (isNewBinaryFieldEnabled != null && isNewBinaryFieldEnabled.equalsIgnoreCase("true")) {
%>
<script src="/html/contenttype-fields.js"></script>
-->
<% } %>

<script type="text/javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,57 @@
%>



<%
String isNewBinaryFieldEnabled = Config.getStringProperty("FEATURE_FLAG_NEW_BINARY_FIELD");
if (isNewBinaryFieldEnabled != null && isNewBinaryFieldEnabled.equalsIgnoreCase("true")) {
%>

<%
String accept="*/*";
String maxFileLength="0";
String helperText="";
List<FieldVariable> acceptTypes=APILocator.getFieldAPI().getFieldVariablesForField(field.getInode(), user, false);
for(FieldVariable fv : acceptTypes){
if("accept".equalsIgnoreCase(fv.getKey())){
accept = fv.getValue();
}
if("maxFileLength".equalsIgnoreCase(fv.getKey())){
maxFileLength=fv.getValue();
}
if("helperText".equalsIgnoreCase(fv.getKey())){
helperText=fv.getValue();
}
}
%>
<dotcms-binary-field id="binary-field-<%=field.getVelocityVarName()%>" fieldName="<%=field.getVelocityVarName()%>"></dotcms-binary-field>
<input name="<%=field.getFieldContentlet()%>" id="binary-field-input-<%=field.getFieldContentlet()%>ValueField" type="hidden" />

<script>
// Create a new scope so that variables defined here can have the same name without being overwritten.
(function autoexecute() {
const binaryField = document.getElementById("binary-field-<%=field.getVelocityVarName()%>");
const field = document.querySelector('#binary-field-input-<%=field.getFieldContentlet()%>ValueField');
// Set the initial value.
binaryField.maxFileSize=Number("<%= maxFileLength%>");
binaryField.accept="<%= accept%>";
binaryField.helperText="<%= helperText%>";
binaryField.addEventListener('tempFile', (event) => {
const tempFile = event.detail;
field.value = tempFile.id;
});
})();
</script>
<%}else{%>

<!-- display -->
<% if(UtilMethods.isSet(value)){
String mimeType="application/octet-stream";
Expand Down Expand Up @@ -829,7 +880,7 @@
</script>


<%} %>
<%
if(UtilMethods.isSet(value) && UtilMethods.isSet(resourceLink)){
Expand Down

0 comments on commit 40f56af

Please sign in to comment.