Exemple #1
0
    def __init__(self, app: object, project_name, out_path):
        self.path = out_path + project_name + "/resources/" + "nav.php.bak"
        set_directory(out_path + project_name + "/resources/")
        self.file = self.set_file()
        self.arr_txt = []

        print("Creando archivo nav.php.bak ...")
        for i, m in enumerate(app["tables"]):
            #if i: self.arr_txt.append(",\n")
            try:
                title = m['title']
            except:
                title = m['name']

            self.arr_txt.append(
                "\t\t\t\t\t@if(auth()->user()->hasPermission('Ver-" +
                m["name"] + "'))\n")
            self.arr_txt.append('\t\t\t\t\t\t<li class="nav-item">\n')
            self.arr_txt.append(
                '\t\t\t\t\t\t\t<a class="nav-link nav-item-pos" href="{{url("/'
                + m["name"] + '")}}">\n')
            self.arr_txt.append('\t\t\t\t\t\t\t\t<span class="sidebar-mini">' +
                                title[0] + '</span>\n')
            self.arr_txt.append(
                '\t\t\t\t\t\t\t\t<span class="sidebar-normal">' + title +
                '</span>\n')
            self.arr_txt.append('\t\t\t\t\t\t\t</a>\n')
            self.arr_txt.append('\t\t\t\t\t\t</li>\n')
            self.arr_txt.append('\t\t\t\t\t@endif\n')

        self.file.writelines(self.arr_txt)
Exemple #2
0
    def __init__(self, app: object, project_name, out_path):
        self.path = out_path + project_name + "/config/" + "log.php.bak"
        set_directory(out_path + project_name + "/config/")
        self.file = self.set_file()
        self.arr_txt = []

        print("Creando archivo log.php.bak ...")
        for i, m in enumerate(app["tables"]):
            if i: self.arr_txt.append(",\n")
            self.arr_txt.append("\t\t\t '" + m["name"].lower() + "'=>'Name'")

            #model_ = js_generator(m["name"],m['fields'],app["name"])
            #model_.create(path= out_path+project_name+"/config/",default_fields=True)
            #model_.set_fields(m["fields"])
        self.file.writelines(self.arr_txt)
Exemple #3
0
    def create(self, path, default_fields=False):

        set_directory(path)
        path = path + "/log.php.bak"
        file = self.set_file(path)

        self.txt.append("//" + str(self.model_name) + "_model \n")
        self.txt.append("var repository= new Repository();\n")
        self.txt.append("var dataTable=null;\n\n")

        #Ready function
        self.txt.append("$(document).ready(function() {\n")
        self.txt.append("\tall();\n")
        self.txt.append(
            "\t$('#showInactive').change(function() {dataTable.draw();});\n")
        self.txt.append("});\n\n")

        #all function
        self.txt.append("function all(){\n")
        self.txt.append("\tdataTable=$('#" + str(self.model_name) +
                        "-table').DataTable({\n")
        self.txt.append("\t\t\t'processing': true,\n")
        self.txt.append("\t\t\t'serverSide': true,\n")
        self.txt.append("\t\t\t'ajax':{\n")
        self.txt.append("\t\t\t\turl: '/" + str(self.model_name) + "/grid',\n")
        self.txt.append("\t\t\t\tdata:function(d){\n")
        self.txt.append(
            "\t\t\t\t\td.inactive=($('#showInactive').is(':checked'))?'1':'0';\n"
        )
        self.txt.append("\t\t\t\t}\n")
        self.txt.append("\t\t\t},\n")
        self.txt.append("\t\t\t'columns': [\n")
        self.txt.extend(self._set_fields())
        self.txt.append("\t\t\t]\n")
        self.txt.append("\t\t});\n")
        self.txt.append("}\n")

        file.writelines(self.txt)
        pass