Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ class GridDataframeController {
render jsonMap as JSON
}

def saveGridData(){
def param = request.getJSON()
//Todo: here after getting selected row data we have to save those data in generic way by finding the correct domain class..
String className = param.tableName
def editableFieldInit = param.editableField
def editableField = editableFieldInit.toLowerCase()
Class clazz = grailsApplication.domainClasses.find { it.clazz.simpleName == className }.clazz
def clazzObject = clazz.findById(param.dataOfSelectedRow.Id)
clazzObject."${editableField}" = param.dataOfSelectedRow."${editableFieldInit}"
clazzObject.save(flush:true)
render(success:true)

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,18 @@ package com.elintegro.erf.dataframe
import com.elintegro.erf.dataframe.vue.DataframeVue
import com.elintegro.erf.dataframe.vue.PageDFRegistryVue
import com.elintegro.erf.dataframe.vue.VueJsBuilder
import com.elintegro.erf.dataframe.vue.ViewRoutes
import com.elintegro.erf.layout.abs.LayoutVue
import com.elintegro.erf.widget.vue.WidgetVue
import com.elintegro.utils.DataframeFileUtil
import grails.plugin.springsecurity.SpringSecurityService
import grails.util.Environment
import groovy.util.logging.Slf4j
import org.apache.tomcat.util.http.fileupload.FileUtils
import org.jsoup.Jsoup
import org.jsoup.nodes.Attributes
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.i18n.LocaleContextHolder

import javax.persistence.MapsId
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths

@Slf4j
class ResultPageHtmlBuilder {

Expand Down Expand Up @@ -85,23 +77,27 @@ class ResultPageHtmlBuilder {
finalScriptSb.append("})\n")

finalScriptSb.append(dfrComps.vueGlobalCompScript) //append globbal dataframe components
finalScriptSb.append(globalLayoutCompScriptSb.toString()) // append global layout components
finalScriptSb.append(layoutStructM.globalComponentScript) // append global layout components
finalScriptSb.append(dfrComps.dfrCompScript) // append other dfr components
finalScriptSb.append(layoutStructM.layoutCompScript) // append other layout components
//Initialize i18n

finalScriptSb.append(""" const i18n = new VueI18n({
locale:'${LocaleContextHolder.getLocale().getLanguage()}',
messages
});""")
});\n""")
//Initialize Router
finalScriptSb.append("const router = new VueRouter({\n")// Initialize Router
// finalScriptSb.append("mode:'history',\n")
/*
finalScriptSb.append(" routes: [\n")
// finalScriptSb.append("{path: '/:routeId', components: {default: $defaultComp, $dfrComps.dfrCompRegisterationScript}},\n")
// finalScriptSb.append(vueRoutes.toString()) // from layouts
finalScriptSb.append(layoutStructM.vueRoutes) // from layouts
finalScriptSb.append(dfrComps.vueRoutes) //from dfrs
finalScriptSb.append("]\n")
*/
finalScriptSb.append(" routes: \n")
finalScriptSb.append(ViewRoutes.constructRoute(gcMainPgObj.viewRoutes))
finalScriptSb.append("})\n")
//Initialize main app
finalScriptSb.append("var app = new Vue ({\nel:'#app',\n") // Vue Instance
Expand All @@ -126,24 +122,28 @@ class ResultPageHtmlBuilder {
finalScriptSb.append("</script>")
return [initHtml:initHmtl, finalScript:finalScriptSb.toString()]
}
public constructLayoutComps(String contLytStr){

LayoutVue contLytObj = LayoutVue.getLayoutVue(contLytStr.trim())
StringBuilder initHtml = new StringBuilder()
String finalLayoutScript = constructFinalLayoutScript(contLytObj, initHtml)
[initHtml: initHtml.toString(), layoutCompScript: finalLayoutScript]
private Map constructDfrComps(List dataframes){
DfrCompBuilder dfrCompBuilder = new DfrCompBuilder()
return dfrCompBuilder.constructDfrComps(dataframes)
}

public Map constructLayoutComps(String containerLayoutName){

LayoutVue constainerLayout = LayoutVue.getLayoutVue(containerLayoutName.trim())
return constainerLayout.constructLayoutComponents()
}

private static String constructCompRegistrationForMainLayout(PageDFRegistryVue gcMainPgObj){
def containerLayoutS = gcMainPgObj.containerLayout

LayoutVue contLytObj = LayoutVue.getLayoutVue(containerLayoutS)
if(!contLytObj.children){
if(!contLytObj.childLayouts){
return ""
}
StringBuilder ltSb = new StringBuilder()
int index = 0;
for(String ltS : contLytObj.children){
for(String ltS : contLytObj.childLayouts){
LayoutVue lytT = LayoutVue.getLayoutVue(ltS)
if(!registeredComponents.contains(ltS)){
ltSb.append(VueJsBuilder.createCompRegistrationString(ltS, index))
Expand All @@ -155,45 +155,6 @@ class ResultPageHtmlBuilder {
return ltSb.toString()
}

private String constructFinalLayoutScript(LayoutVue contLytObj, StringBuilder initHtml){
List children = contLytObj.children
String wrapperLayout = contLytObj.layoutPlaceHolder
StringBuilder resultPageScript = new StringBuilder()
if(children.isEmpty()){
return ""
}
for(String ch : children){
if(ch.trim() != "") {
LayoutVue layoutObj = LayoutVue.getLayoutVue(ch)
prepareVueLayout(layoutObj.children, resultPageScript, layoutObj)
}
}
initHtml.append(wrapperLayout)
return resultPageScript.toString()
}

private def prepareVueLayout(children, resultPageScript, disObj){
if(children.isEmpty()){
constructSectionalComponent(resultPageScript, disObj)
return
}
for(String ch : children){
if(builtComponents.contains(ch)){
continue
}
if(ch.trim() != ""){
LayoutVue layoutObj = LayoutVue.getLayoutVue(ch)
if(!registeredComponents.contains(ch) && !layoutObj.isGlobal) {
disObj.compRegScript.append(VueJsBuilder.createCompRegistrationString(ch))
registeredComponents.add(ch)
}
List childs = layoutObj.children
prepareVueLayout(childs, resultPageScript, layoutObj)
}
}
constructSectionalComponent(resultPageScript, disObj)
}

private String getMainPgVueCompRegistrationString(PageDFRegistryVue gcMainPgObj){
def mainPageDataframeList= gcMainPgObj.dataframesToShowInMainPage
if(!mainPageDataframeList){
Expand All @@ -213,49 +174,6 @@ class ResultPageHtmlBuilder {
return sb.toString()
}

private void constructSectionalComponent(StringBuilder resultPageScript, LayoutVue disObj){
StringBuilder compBuilder = new StringBuilder()
String layoutPlaceHolder = disObj.layoutPlaceHolder
String layoutName = disObj.layoutBeanName
String formatPlaceholder = "["+layoutName + "]"
if(disObj.isGlobal){
compBuilder.append("Vue.component('${layoutName}',{\n")
compBuilder.append("name: '${layoutName}',\n")
disObj.componentRegistered = true
}else{
disObj.componentRegistered = false
compBuilder.append("const ${layoutName}Comp = {\n")
}
compBuilder.append("template:`")
compBuilder.append(layoutPlaceHolder)
compBuilder.append("`,\n")
compBuilder.append("components:{\n") //register embedded components
compBuilder.append(disObj.compRegScript.toString())
disObj.compRegScript.setLength(0) //Resetting compRegScript for another layout obj
if(!disObj.childDataframes.isEmpty()){
for(String compS : disObj.childDataframes){
if(!registeredComponents.contains(compS)){
compBuilder.append(VueJsBuilder.createCompRegistrationString(compS))
registeredComponents.add(compS)
}
}
}
compBuilder.append("},\n")
if(disObj.isGlobal){
compBuilder.append("})\n")
globalLayoutCompScriptSb.append(compBuilder.toString())
}else{
compBuilder.append("}\n")
resultPageScript.append(compBuilder.toString())
}
builtComponents.add(layoutName) // Add the built components to this List. Remove later if not used.
}

private Map constructDfrComps(dataframes){
DfrCompBuilder dfrCompBuilder = new DfrCompBuilder()
return dfrCompBuilder.constructDfrComps(dataframes)
}


public String applySecurityFilter(String resultPage /*, SpringSecurityService springSecurityService*/){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,24 @@ public class DFButton {
public String doBeforeSave; // Script just before Ajax save
public String doAfterSave=""; // Script just after Ajax save
public boolean showAsDialog = false; //Show the refDataframe as Dialog??
public boolean showToolbar = false;
public boolean route = false; // Show as Route??
public Map routeMap;
public Map tooltip;
public String attr; //add extra attribbubtes from descripter
public String layout=""; // layout for buttons
public String doBeforeAjax; // Script just bbefore ajax call
public String routeIdScript; //Id for the dataframe when route is true
public List flexGridValues; //grid values for v-flex
public String routeName; //route name to appear in the url
public String doAfterRoute; //If we have to do something after routing the page
public Map cssGridValues; //grid values for v-col
public Map showAsMenu;
public String attachTo; //Attch the menu to another field
public String roles; //"ROLE_ADMIN,ROLE_CUSTOMER"
public String accessType; //ifAllGranted, ifAnyGranted (deafualt)
public String classNames;
public boolean scrollable;
public boolean persistent;
public String dialogBoxWidth;
public String dialogBoxMaxWidth;

}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public class Dataframe extends DataframeSuperBean implements Serializable, DataF
def ajaxInsertUrl = "dataframe/ajaxInsert";
def ajaxDefaultUrl = "dataframe/ajaxDefaultData";
def ajaxCreateUrl ="dataframe/ajaxCreateNew"
def ajaxFileSaveUrl = "fileUpload/ajaxFileSave"

public static Dataframe getDataframeByName(String dataframeName){
return (Dataframe) Holders.grailsApplication.mainContext.getBean(dataframeName)
Expand Down Expand Up @@ -481,7 +482,7 @@ public class Dataframe extends DataframeSuperBean implements Serializable, DataF
addField(key, value)
}
//Todo: We need to refactor it soon...
// addField("alertMesssage", [widget: "SnackbarWidgetVue",flexGridValues: ['xs0', 'sm0', 'md0', 'lg0', 'xl0'],])
// addField("alertMesssage", [widget: "SnackbarWidgetVue",cssGridValues: ['xs0', 'sm0', 'md0', 'lg0', 'xl0'],])
}

List getHqlResult(def queryHql){
Expand Down Expand Up @@ -725,7 +726,7 @@ public class Dataframe extends DataframeSuperBean implements Serializable, DataF
this.currentFrameLayout.numberFields = fields.getList().size()
getAdditionalDataFromAjax(additionalParameters)
String additionalParametersStr = additionalParameters.toString()
doAfterSaveStringBuilder.append(doAfterSave)
//doAfterSaveStringBuilder.append(doAfterSave)
def ajaxSavescripts = """
<script>
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class DataframeInstance implements DataframeConstants{
String refFieldName = namedParam[1];
String keyNamedParam = DataframeVue.buildFullFieldNameKeyParamWithDot(df, refDomainAlias, refFieldName, key);
// jsonMapDf.put(keyNamedParam, value)
jsonMapDf.put("$refDomainAlias",["$refFieldName": value, "$key":value]) //todo check if this works for all cases
jsonMapDf.put(refDomainAlias,[(refFieldName): value, (key):value]) //todo check if this works for all cases

jData?."${DOMAIN_KEYS}".putAll(jsonMapDf)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,21 @@ public class DataframeViewJqxVue implements DataframeView {
} else {
if(refDataframe){
String refDfrName = refDataframe.dataframeName
if(dfButton.route){
String routeIdScript = dfButton.routeIdScript
if(dfButton.route || dfButton.routeMap){
String routeName = dfButton.routeName?:(dfButton.name?:refDfrName)
String doAfterRoute = dfButton.doAfterRoute?:""
String path = (dfButton.routeMap && dfButton.routeMap.path)?dfButton.routeMap.path:routeName
ResultPageHtmlBuilder.registeredComponents.add(refDataframe.dataframeName)
script.append("""${dataframeName}_${dfButton.name}: function(_param){\n
$doBeforeAjax
var routeId = ${routeIdScript?:0}
this.\$router.push({
name: '$refDfrName',
path: '$refDfrName',
path: '/$path',
params: {
$refDfrName: "test",
routeId: routeId
$refDfrName: "test"
}
})
});
$doAfterRoute
},\n""")
}else {
script.append("""${dataframeName}_${dfButton.name}: function(){\n
Expand Down Expand Up @@ -124,10 +125,25 @@ public class DataframeViewJqxVue implements DataframeView {
if(dfButton.showAsDialog){
String scrollable = dfButton.scrollable?"scrollable":""
String persistent = dfButton.persistent?"persistent":""
resultPageHtml.append("""<v-dialog v-model="visibility.${refDataframeName}" $scrollable $persistent width='initial' :retain-focus="false" max-width='500px'>""")
String dialogBoxWidth = dfButton.dialogBoxWidth?:"initial"
String dialogBoxMaxWidth = dfButton.dialogBoxMaxWidth?:"500px"
resultPageHtml.append("""<v-dialog v-model="visibility.${refDataframeName}" $scrollable $persistent width = '$dialogBoxWidth' :retain-focus="false" max-width = '$dialogBoxMaxWidth'>""")
resultPageHtml.append("""<v-card>""")
if(dfButton.showToolbar) {
resultPageHtml.append("""
<v-toolbar dark color="blue darken-2" class="mb-5">
<v-toolbar-title>[DATAFRAME_LABEL]</v-toolbar-title>
<v-spacer></v-spacer>
<v-tooltip bottom>
<v-btn icon target="_blank" slot="activator" @click.prevent="closeDataframe">
<v-icon medium >close</v-icon>
</v-btn><span>Close</span>
</v-tooltip>
</v-toolbar>""")
}
resultPageHtml.append(refDataframe.getComponentName("resetForm=true"))
// resultPageHtml.append("""<component :is='${refDataframeName.toLowerCase()}' ref='${refDataframeName.toLowerCase()}_ref' :${refDataframeName}_prop="${refDataframeName}_data" :key='randomKey'></component>""")
resultPageHtml.append("""</v-dialog>\n""")
resultPageHtml.append("""</v-card></v-dialog>\n""")
} else if(dfButton.showAsMenu && dfButton.showAsMenu.attr){
String attr = dfButton.showAsMenu.attr?:"left"
String attachTo = dfButton.showAsMenu.attachTo?:"$dataframeName-id"
Expand Down
Loading