Skip to content

Commit

Permalink
dev: create file preview component
Browse files Browse the repository at this point in the history
  • Loading branch information
rjvelazco committed Oct 17, 2023
1 parent f96d43e commit 14ef42b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>dot-binary-field-preview works!</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { DotBinaryFieldPreviewComponent } from './dot-binary-field-preview.component';

describe('DotBinaryFieldPreviewComponent', () => {
let component: DotBinaryFieldPreviewComponent;
let fixture: ComponentFixture<DotBinaryFieldPreviewComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DotBinaryFieldPreviewComponent]
}).compileComponents();

fixture = TestBed.createComponent(DotBinaryFieldPreviewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
selector: 'dot-dot-binary-field-preview',
standalone: true,
imports: [CommonModule],
templateUrl: './dot-binary-field-preview.component.html',
styleUrls: ['./dot-binary-field-preview.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DotBinaryFieldPreviewComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<%@page import="com.dotmarketing.portlets.structure.business.FieldAPI"%>
<%@page import="com.dotmarketing.portlets.structure.model.Field"%>
<%@page import="com.dotmarketing.portlets.structure.model.FieldVariable"%>

<%@ include file="/html/portlet/ext/contentlet/init.jsp"%>

<%@page import="com.dotmarketing.portlets.structure.model.Structure"%>
Expand All @@ -38,6 +39,7 @@
<%@ page import="com.dotmarketing.beans.Host" %>
<%@ page import="com.dotcms.contenttype.model.field.JSONField" %>
<%@ page import="org.apache.commons.lang.StringEscapeUtils" %>
<%@ page import="com.fasterxml.jackson.databind.ObjectMapper" %>

<%
long defaultLang = APILocator.getLanguageAPI().getDefaultLanguage().getId();
Expand Down Expand Up @@ -663,6 +665,14 @@
String maxFileLength="0";
String helperText="";
Contentlet contentletObj = APILocator.getContentletAPI().find(inode, user, false);
// Create an ObjectMapper instance
ObjectMapper mapper = new ObjectMapper();
// Convert the contentlet object to JSON string
String json = mapper.writeValueAsString(contentlet);
List<FieldVariable> acceptTypes=APILocator.getFieldAPI().getFieldVariablesForField(field.getInode(), user, false);
for(FieldVariable fv : acceptTypes){
if("accept".equalsIgnoreCase(fv.getKey())){
Expand All @@ -676,7 +686,6 @@
helperText=fv.getValue();
}
}
%>

Expand Down

0 comments on commit 14ef42b

Please sign in to comment.