Esempio n. 1
0
        /// <inheritdoc/>
        public string Enable(string noParameterOrder = "random-y023n", bool?js = null, bool?api = null,
                             bool?forms = null, bool?context = null, bool?autoToolbar           = null, bool?styles = null)
        {
            Eav.Constants.ProtectAgainstMissingParameterNames(noParameterOrder, "Enable", $"{nameof(js)},{nameof(api)},{nameof(forms)},{nameof(context)},{nameof(autoToolbar)},{nameof(autoToolbar)},{nameof(styles)}");

            // check if feature enabled - if more than the api is needed
            // extend this list if new parameters are added
            if (forms.HasValue || styles.HasValue || context.HasValue || autoToolbar.HasValue)
            {
                var feats = new[] { FeatureIds.PublicForms };
                if (!Feats.EnabledOrException(feats, "public forms not available", out var exp))
                {
                    throw exp;
                }
            }

            // find the root host, as this is the one we must tell what js etc. we need
            var hostWithInternals = (BlockBuilder)Block.BlockBuilder.RootBuilder;

            if (js.HasValue || api.HasValue || forms.HasValue)
            {
                hostWithInternals.UiAddJsApi = (js ?? false) || (api ?? false) || (forms ?? false);
            }

            // only update the values if true, otherwise leave untouched
            if (api.HasValue || forms.HasValue)
            {
                hostWithInternals.UiAddEditApi = (api ?? false) || (forms ?? false);
            }

            if (styles.HasValue)
            {
                hostWithInternals.UiAddEditUi = styles.Value;
            }

            if (context.HasValue)
            {
                hostWithInternals.UiAddEditContext = context.Value;
            }

            if (autoToolbar.HasValue)
            {
                hostWithInternals.UiAutoToolbar = autoToolbar.Value;
            }

            return(null);
        }
Esempio n. 2
0
        public string Enable(string dontRelyOnParameterOrder = Constants.RandomProtectionParameter, bool?api = null, bool?forms = null, bool?context = null, bool?autoToolbar = null, bool?styles = null)
        {
            Constants.ProtectAgainstMissingParameterNames(dontRelyOnParameterOrder, "Enable", $"{nameof(api)},{nameof(forms)},{nameof(context)},{nameof(autoToolbar)},{nameof(autoToolbar)},{nameof(styles)}");

            // check if feature enabled
            var feats = new[] { FeatureIds.PublicForms };

            if (!Feats.EnabledOrException(feats, "public forms not available", out var exp))
            {
                throw exp;
            }
            //if (!Feats.Enabled(feats))
            //    throw new Exception($"public forms not available - {Feats.MsgMissingSome(feats)}");

            // only update the values if true, otherwise leave untouched
            if (api.HasValue || forms.HasValue)
            {
                SxcInstance.UiAddEditApi = api ?? forms.Value;
            }

            if (styles.HasValue)
            {
                SxcInstance.UiAddEditUi = styles.Value;
            }

            if (context.HasValue)
            {
                SxcInstance.UiAddEditContext = context.Value;
            }

            if (autoToolbar.HasValue)
            {
                SxcInstance.UiAutoToolbar = autoToolbar.Value;
            }

            return(null);
        }