Example #1
0
        /// <summary>
        /// Retrieve the specific menu for a concern.
        /// </summary>
        /// <param name="concern">A concern.</param>
        /// <returns>A dictionary of the menu.</returns>
        public static Dictionary <string, string> GetMenu(this ConcernInfo concern)
        {
            var menu = new Dictionary <string, string>();

            if (!concern.IsValid())
            {
                return(menu);
            }

            if (concern.Layouts.IsValid())
            {
                foreach (var layout in concern.Layouts)
                {
                    if (layout.IsValid() &&
                        layout.Title.IsValid() &&
                        layout.IsVisibleInMenu &&
                        !menu.Any(item =>
                                  item.Key == $"{concern.Id.ToCamelCase()}-{layout.Id.ToCamelCase()}"))
                    {
                        menu.Add(
                            $"{concern.Id.ToCamelCase()}-{layout.Id.ToCamelCase()}",
                            layout.Title);
                    }
                }
            }

            return(menu);
        }
        public AppBaseClass(SmartAppInfo smartApp) : base(smartApp)
        {
            Tuple <LayoutInfo, ConcernInfo> tuple = getRootLayout(smartApp);

            _rootLayout  = tuple.Item1;
            _rootConcern = tuple.Item2;
        }
Example #3
0
        public ContainerTemplate(ConcernInfo concern, LayoutInfo layout)
        {
            _concern = concern;
            _layout  = layout;

            _navigationActions = _layout.Actions.Where(r => r.Type.ToLower()
                                                       .Equals("navigation")).ToList <ActionInfo>();
        }
Example #4
0
 public LayoutViewTemplate(string smartAppTitle, ConcernInfo concern, LayoutInfo layout, LanguageList languages)
 {
     _smartAppTitle = smartAppTitle;
     _concern       = concern;
     _layout        = layout;
     _languages     = languages;
     _menu          = getMenu(_concern);
 }
Example #5
0
        public static bool IsValid(this ConcernInfo concern)
        {
            if (concern == null ||
                !concern.Id.IsValid())
            {
                return(false);
            }

            return(true);
        }
Example #6
0
 public LayoutComponentTemplate(ConcernInfo concern, LayoutInfo layout, LanguageList languages, ApiList api)
 {
     if (concern != null && concern.Id != null)
     {
         _concernId = concern.Id;
     }
     _layout     = layout;
     _languages  = languages;
     _api        = api;
     _viewModels = new List <string>();
     getViewModels(layout, api);
     _apiDomainServices = getApiDomainServices(api, layout);
     _menu = getMenu(concern);
 }
Example #7
0
 public ComponentSpecTemplate(string smartAppId, ConcernInfo concern, LayoutInfo layout, LanguageList languages, ApiList api)
 {
     _smartAppId = smartAppId;
     if (concern != null && concern.Id != null)
     {
         _concernId = concern.Id;
     }
     _layout     = layout;
     _languages  = languages;
     _api        = api;
     _viewModels = new List <string>();
     getViewModels(layout, api);
     _apiDomainServices = getApiDomainServices(api, layout);
 }
        /// <summary>
        /// Generating an angular component containing routing definition
        /// and controls for the current layout.
        /// Ionic 2 recommends a component for each page. One page = one layout.
        /// </summary>
        /// <param name="concern">A concern.</param>
        /// <param name="layout">A layout.</param>
        /// <param name="languages">A list of languages. (can be null)</param>
        /// <param name="api">A list of apis.</param>
        public void TransformLayoutComponent(ConcernInfo concern, LayoutInfo layout, LanguageList languages, ApiList api)
        {
            if (concern != null && concern.Id != null && layout != null && layout.Id != null && api != null)
            {
                LayoutComponentTemplate layoutComponentTemplate = new LayoutComponentTemplate(concern, layout, languages, api);

                string layoutComponentDirectoryPath = Path.Combine(layoutComponentTemplate.OutputPath, TextConverter.CamelCase(concern.Id), TextConverter.CamelCase(layout.Id));
                string layoutComponentFilename      = TextConverter.CamelCase(concern.Id) + "-" + TextConverter.CamelCase(layout.Id) + ".ts";

                string fileToWritePath = Path.Combine(_context.BasePath, layoutComponentDirectoryPath, layoutComponentFilename);
                string textToWrite     = layoutComponentTemplate.TransformText();

                _writingService.WriteFile(fileToWritePath, textToWrite);
            }
        }
        /// <summary>
        /// Generating a HTML file containing the view description for the
        /// current layout.
        /// Ionic 2 recommends a HTML file for each page. One page = one layout.
        /// </summary>
        /// <param name="smartAppTitle">A SmartApp title.</param>
        /// <param name="concern">A concern.</param>
        /// <param name="layout">A layout.</param>
        /// <param name="languages">A list of languages. (can be null)</param>
        public void TransformLayoutView(string smartAppTitle, ConcernInfo concern, LayoutInfo layout, LanguageList languages)
        {
            // languages can be null
            if (smartAppTitle != null && concern != null && concern.Id != null && layout != null && layout.Id != null)
            {
                LayoutViewTemplate layoutViewTemplate = new LayoutViewTemplate(smartAppTitle, concern, layout, languages);

                string layoutViewDirectoryPath = Path.Combine(layoutViewTemplate.OutputPath, TextConverter.CamelCase(concern.Id), TextConverter.CamelCase(layout.Id));
                string layoutViewFilename      = TextConverter.CamelCase(concern.Id) + "-" + TextConverter.CamelCase(layout.Id) + ".html";

                string fileToWritePath = Path.Combine(_context.BasePath, layoutViewDirectoryPath, layoutViewFilename);
                string textToWrite     = layoutViewTemplate.TransformText();

                _writingService.WriteFile(fileToWritePath, textToWrite);
            }
        }
        /// <summary>
        /// Retrieve the specific menu for each concern.
        /// </summary>
        /// <param name="concern">A concern.</param>
        public Dictionary <string, string> getMenu(ConcernInfo concern)
        {
            Dictionary <string, string> menu = new Dictionary <string, string>();

            if (concern != null && concern.Id != null && concern.Layouts.AsEnumerable() != null)
            {
                foreach (LayoutInfo layout in concern.Layouts.AsEnumerable())
                {
                    if (layout.IsVisibleInMenu && layout.Id != null && layout.Title != null && !menu.ContainsKey(TextConverter.CamelCase(concern.Id) + "-" + TextConverter.CamelCase(layout.Id)))
                    {
                        menu.Add(TextConverter.CamelCase(concern.Id) + "-" + TextConverter.CamelCase(layout.Id), layout.Title);
                    }
                }
            }
            return(menu);
        }
        public ViewTemplate(string smartAppTitle, ConcernInfo concern, LayoutInfo layout, LanguageList languages, ApiList api, string apiSuffix, string viewModelSuffix)
        {
            _smartAppTitle   = smartAppTitle;
            _concern         = concern;
            _layout          = layout;
            _languages       = languages;
            _api             = api;
            _viewModelSuffix = TextConverter.PascalCase(viewModelSuffix);
            _apiSuffix       = TextConverter.PascalCase(apiSuffix);

            _viewModels = new List <string>();

            getViewModels(layout, api);

            _apiDomainServices = getApiDomainServices(api, layout);

            _menu = getMenu(_concern);
        }
        /// <summary>
        /// Convert an IEnumerable to a LayoutList
        /// </summary>
        /// <param name="layouts">A list of LayoutInfo objects.</param>
        /// <param name="parent">A ConcernInfo object.</param>
        /// <returns>A LayoutList</returns>
        public static LayoutList ToLayoutList(
            this IEnumerable <LayoutInfo> layouts,
            ConcernInfo parent)
        {
            var result = new LayoutList();

            if (parent.IsValid())
            {
                foreach (var layout in layouts)
                {
                    if (layout.IsValid())
                    {
                        result.Add(layout);
                        result.Last().Parent = parent;
                    }
                }
            }

            return(result);
        }
Example #13
0
        /// <summary>
        /// Retrieve all direct references from a concern.
        /// </summary>
        /// <param name="concern">A ConcernInfo object.</param>
        /// <returns>A list of EntityInfo.</returns>
        public static List <EntityInfo> GetConcernDirectReferences(this ConcernInfo concern)
        {
            var directReferences = new List <EntityInfo>();

            if (!concern.IsValid())
            {
                return(directReferences);
            }

            var entityComparer = new EntityInfoComparer();

            if (concern.Layouts.IsValid())
            {
                directReferences = directReferences
                                   .Union(
                    concern.Layouts.GetLayoutListDirectReferences(),
                    entityComparer)
                                   .ToList();
            }

            return(directReferences);
        }
 public ReducersTemplate(ConcernInfo concern, LayoutInfo layout)
 {
     _concern = concern;
     _layout  = layout;
 }
Example #15
0
 public NavigationTemplate(SmartAppInfo smartApp, ConcernInfo concernInfo) : base(smartApp)
 {
     _concernInfo = concernInfo;
 }
Example #16
0
 public ActionsTemplate(ConcernInfo concern, LayoutInfo layout)
 {
     _concern = concern;
     _layout  = layout;
 }