Esempio n. 1
0
        public string MakeTemplateEnd(VueComponentContext context)
        {
            return($@"
  </div>
</template>
");
        }
Esempio n. 2
0
        public string MakeCss(VueComponentContext context)
        {
            return($@"
<style lang=""css"">

</style>
");
        }
Esempio n. 3
0
        public string MakeScript(VueComponentContext context)
        {
            StringBuilder lines = new StringBuilder();

            lines.Append(MakeRawScript());

            return(lines.ToString());
        }
Esempio n. 4
0
        public string MakeFileHeader(VueComponentContext context)
        {
            return($@"<!--
Brash Generated: { DateTime.Now }
Domain: { context.Domain }
Entity: { context.EntityName }
-->
");
        }
Esempio n. 5
0
        public string MakeTemplateLoadingSpinner(VueComponentContext context)
        {
            return($@"
  <!-- loading spinner -->
  <div class=""row justify-content-md-center"" v-if=""isLoading()"">
    <div class=""spinner-border text-primary""></div>
  </div>

");
        }
Esempio n. 6
0
        public string MakeTemplateAlertBox(VueComponentContext context)
        {
            return($@"
  <!-- alert box -->
  <div class=""alert alert-primary alert-dismissible fade show"" :class=""{{ alertCssClass }}"" v-if=""hasAlert()"">
    <button type=""button"" class=""close"" @click=""hideAlert()"">&times;</button>
    {{{{ alertMessage }}}}
  </div>

");
        }
Esempio n. 7
0
        public string MakeTemplateStart(VueComponentContext context)
        {
            return($@"<template>
  <div class=""container-fluid h-100"">

    <div class=""row justify-content-md-center"">
      <h2>{ context.EntityName }</h2>
    </div>            

");
        }
Esempio n. 8
0
        private (List <string> headers, string headerText) MakeListingHeaders(VueComponentContext context)
        {
            StringBuilder lines   = new StringBuilder();
            List <string> headers = new List <string>();

            headers.Add("Action");

            foreach (var field in context.Entity.Fields)
            {
            }

            return(headers, lines.ToString());
        }
Esempio n. 9
0
        public string TplVueComponent(
            string domain
            , Structure entity
            , Structure parent
            )
        {
            VueComponentContext context = new VueComponentContext(domain, entity, parent);
            StringBuilder       lines   = new StringBuilder();

            lines.Append(MakeFileHeader(context));
            lines.Append(MakeTemplate(context));
            lines.Append(MakeScript(context));
            lines.Append(MakeCss(context));

            return(lines.ToString());
        }
Esempio n. 10
0
        public string MakeTemplate(VueComponentContext context)
        {
            StringBuilder lines = new StringBuilder();

            lines.Append(MakeTemplateStart(context));

            lines.Append(MakeTemplateAlertBox(context));
            lines.Append(MakeTemplateLoadingSpinner(context));
            lines.Append(MakeTemplateCardStart(context));
            lines.Append(MakeListing(context));
            lines.Append(MakeForm(context));
            lines.Append(MakeTemplateCardEnd(context));

            lines.Append(MakeTemplateEnd(context));

            return(lines.ToString());
        }
Esempio n. 11
0
        public string MakeTemplateCardStart(VueComponentContext context)
        {
            return($@"
  <!-- title bar -->
  <div class=""row no-gutters"">
    <div class=""card col-12"">
      <div class=""card-header"">
        <ul class=""nav nav-tabs card-header-tabs"">
          <li class=""nav-item"">
            <a class=""nav-link"" href=""#"" :class=""isListingVisible() ? 'active' : ''"" @click=""showListing()"">Listing</a>
          </li>
          <li class=""nav-item"" >
            <a class=""nav-link"" href=""#"" :class=""isFormVisible() ? 'active' : ''"" @click=""showForm()"">Form</a>
          </li>
        </ul>
      </div>

      <div class=""card-body"">

");
        }
Esempio n. 12
0
        public string MakeForm(VueComponentContext context)
        {
            StringBuilder lines = new StringBuilder();

            // start form
            var start = $@"
          <!-- form -->
          <div class=""row justify-content-md-center"" v-if=""isFormVisible()"">
            <form class=""col col-lg-6 col-md-10 col-sm-12"" @submit.prevent=""onSave"">
          ";

            lines.Append(start);

            // add primary key
            switch (context.IdPattern)
            {
            case Global.IDPATTERN_ASKVERSION:
                lines.Append(MakePrimaryKeyFormField("ID", $"{context.EntityInstanceName}Id"));
                lines.Append(MakePrimaryKeyFormField("GUID", $"{context.EntityInstanceName}Guid"));
                lines.Append(MakePrimaryKeyFormField("VERSION", $"{context.EntityInstanceName}RecordVersion"));
                lines.Append(MakePrimaryKeyFormField("Current", "IsCurrent"));
                break;

            case Global.IDPATTERN_ASKGUID:
                lines.Append(MakePrimaryKeyFormField("ID", $"{context.EntityInstanceName}Id"));
                lines.Append(MakePrimaryKeyFormField("GUID", $"{context.EntityInstanceName}Guid"));
                break;

            case Global.IDPATTERN_ASKID:
            default:
                lines.Append(MakePrimaryKeyFormField("ID", $"{context.EntityInstanceName}Id"));
                break;
            }
            ;

            // add fields
            if (context.Entity.Fields != null && context.Entity.Fields.Count > 0)
            {
                foreach (var field in context.Entity.Fields)
                {
                    if (field.Type == "D")
                    {
                        lines.Append(MakeDateFormField(field.Name, ToLowerFirstChar(field.Name)));
                    }
                    else
                    {
                        lines.Append(MakeTextFormField(field.Name, ToLowerFirstChar(field.Name)));
                    }
                }
            }

            // add references
            if (context.Entity.References != null && context.Entity.References.Count > 0)
            {
                foreach (var reference in context.Entity.References)
                {
                    lines.Append(MakeReferenceFormField(reference));
                }
            }

            // end form
            var end = $@"
              <div class=""form-group row"">
                <div class=""col-12"">
                  <button type=""reset"" class=""btn btn-warning float-right"" title=""clear"" @click=""onReset"">Clear</button>
                  <button type=""submit"" class=""btn btn-primary float-right"">Save</button>
                </div>
              </div>
              <br />
              <br />

            </form>
          </div>        

";

            lines.Append(end);

            return(lines.ToString());
        }
Esempio n. 13
0
        public string MakeListing(VueComponentContext context)
        {
            StringBuilder headerLines = new StringBuilder();
            StringBuilder valueLines  = new StringBuilder();
            List <string> headers     = new List <string>();
            List <string> values      = new List <string>();

            // add action
            headers.Add("Action");

            // add primary key
            switch (context.IdPattern)
            {
            case Global.IDPATTERN_ASKVERSION:
                headers.Add("ID");
                headers.Add("GUID");
                headers.Add("VER");
                headers.Add("Current");
                values.Add($@"item.{context.EntityInstanceName}Id");
                values.Add($@"item.{context.EntityInstanceName}Guid");
                values.Add($@"item.{context.EntityInstanceName}RecordVersion");
                values.Add($@"item.IsCurrent");
                break;

            case Global.IDPATTERN_ASKGUID:
                headers.Add("ID");
                headers.Add("GUID");
                values.Add($@"item.{context.EntityInstanceName}Id");
                values.Add($@"item.{context.EntityInstanceName}Guid");
                break;

            case Global.IDPATTERN_ASKID:
            default:
                headers.Add("ID");
                values.Add($@"item.{context.EntityInstanceName}Id");
                break;
            }
            ;

            // add fields
            if (context.Entity.Fields != null && context.Entity.Fields.Count > 0)
            {
                foreach (var field in context.Entity.Fields)
                {
                    headers.Add($@"{field.Name}");
                    if (field.Type == "D")
                    {
                        values.Add($@"translateDateTime(item.{field.Name})");
                    }
                    else
                    {
                        values.Add($@"item.{field.Name}");
                    }
                }
            }

            // add references
            if (context.Entity.References != null && context.Entity.References.Count > 0)
            {
                foreach (var reference in context.Entity.References)
                {
                    headers.Add($@"{reference.ColumnName}");
                    values.Add($@"translate{reference.TableName}Id(item.{reference.ColumnName})");
                }
            }

            // make header tags
            foreach (var header in headers)
            {
                headerLines.Append($@"<th scope=""col"">{{{{ {header} }}}}</th>" + "\n                  ");
            }

            // make value tags
            foreach (var value in values)
            {
                valueLines.Append($@"<td>{{{{ {value} }}}}</td>" + "\n                  ");
            }


            var text = $@"
          <!-- table listing -->
          <div class=""row justify-content-md-center"" v-if=""isListingVisible()"">
            <table class=""table"">
              <thead class=""thead-light"">
                <tr>
                  <th scope=""col"" colspan=""{headers.Count}"">
                    <button class=""btn btn-success btn-sm float-right"" title=""add new"" @click=""addForm()"">
                      <i class=""material-icons"" style=""font-size:12px;"">add</i>
                    </button>
                    <button class=""btn btn-primary btn-sm float-right"" title=""refresh listing"" @click=""onGetListing(true)"">
                      <i class=""material-icons"" style=""font-size:12px;"">refresh</i>
                    </button>
                  </th>
                </tr>
              </thead>
              <thead class=""thead-dark"">
                <tr>
                  {headerLines.ToString()}
                </tr>
              </thead>
              <tbody>
                <tr v-for='(item, index) in this.items' :key='item.todoEntryId'>
                  <td>
                    <button class=""btn btn-danger btn-sm"" title=""remove"" @click=""onRemove(index)"">
                      <i class=""material-icons"" style=""font-size:12px;"">delete</i>
                    </button>
                    <button class=""btn btn-secondary btn-sm"" title=""edit"" @click=""onEdit(index)"">
                      <i class=""material-icons"" style=""font-size:12px;"">edit</i>
                    </button>
                  </td>
                  {valueLines.ToString()}
                </tr>
              </tbody>
            </table>
          </div>        

";

            return(text);
        }