How to use the mithril.prop function in mithril

To help you get started, we’ve selected a few mithril examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github catarse / catarse.js / src / vms / payment-vm.js View on Github external
};

    const fields = {
        completeName: m.prop(''),
        anonymous: h.toggleProp(false, true),
        address: m.prop({ country_id: defaultCountryID }),
        ownerDocument: m.prop(''),
        errors: m.prop([])
    };

    const creditCardFields = {
        name: m.prop(''),
        number: m.prop(''),
        expMonth: m.prop(''),
        expYear: m.prop(''),
        save: m.prop(false),
        cvv: m.prop(''),
        errors: m.prop([]),
        cardOwnerDocument: m.prop('')
    };

    const populateForm = (fetchedData) => {
        const data = _.first(fetchedData) || { address: {} };

        if (!_.isEmpty(data.address)) {
            fields.address(_.omit(data.address, 'id'));
        }

        fields.completeName(data.name);
        fields.ownerDocument(data.owner_document);

        creditCardFields.cardOwnerDocument(data.owner_document);
github ArthurClemens / polythene / ripple / ripple.es6 View on Github external
controller: () => {
        return {
            ripple: m.prop(),
            waves: m.prop(),
            delegate: m.prop()
        };
    },
    view: (ctrl, opts = {}) => {
github jsguy / misojs / c / todo.js View on Github external
var Todo = function(data) {
    this.description = m.prop(data.description);
    this.done = m.prop(false);
};
github catarse / catarse.js / legacy / src / c / project-insights.js View on Github external
controller: function(args) {
        const filtersVM = args.filtersVM,
            displayModal = h.toggleProp(false, true),
            contributionsPerDay = m.prop([]),
            visitorsTotal = m.prop(0),
            visitorsPerDay = m.prop([]),
            loader = catarse.loaderWithToken;

        if (h.paramByName('online_success') === 'true') {
            displayModal.toggle();
        }

        const processVisitors = (data) => {
            if (!_.isEmpty(data)) {
                visitorsPerDay(data);
                visitorsTotal(_.first(data).total);
            }
        };

        const lVisitorsPerDay = catarseMoments.loaderWithToken(models.projectVisitorsPerDay.getRowOptions(filtersVM.parameters()));
        lVisitorsPerDay.load().then(processVisitors);
github catarse / catarse.js / legacy / src / c / user-notifications.js View on Github external
controller: function(args) {
        const contributedProjects = m.prop(),
            projectReminders = m.prop(),
            mailMarketingLists = m.prop(),
            user_id = args.userId,
            showNotifications = h.toggleProp(false, true),
            error = m.prop(false);

        userVM.getUserProjectReminders(user_id).then(
            projectReminders
        ).catch((err) => {
            error(true);
            m.redraw();
        });

        userVM.getMailMarketingLists().then((data) => {
            mailMarketingLists(generateListHandler(data));
        }
        ).catch((err) => {
            error(true);
github catarse / catarse.js / legacy / src / c / user-notifications.js View on Github external
return _.map(list, (item, i) => {
                const user_signed = !_.isEmpty(user_lists) && !_.isUndefined(_.find(user_lists, userList => userList.marketing_list ? userList.marketing_list.list_id === item.list_id : false));
                const handler = {
                    item,
                    in_list: user_signed,
                    should_insert: m.prop(false),
                    should_destroy: m.prop(false),
                    isInsertInListState: h.toggleProp(false, true),
                    hovering: m.prop(false)
                };
                handler.isInsertInListState(!handler.in_list);
                return handler;
            });
        };
github catarse / catarse.js / src / c / user-private-contributed.js View on Github external
controller: function(args) {
        const user_id = args.userId,
            userCommonId = args.user && args.user.common_id,
            subscriptions = commonPayment.paginationVM(models.userSubscription),
            onlinePages = catarse.paginationVM(models.userContribution),
            successfulPages = catarse.paginationVM(models.userContribution),
            failedPages = catarse.paginationVM(models.userContribution),
            error = m.prop(false),
            loader = m.prop(true),
            handleError = () => {
                error(true);
                loader(false);
                m.redraw();
            },
            contextVM = catarse.filtersVM({
                user_id: 'eq',
                state: 'in',
                project_state: 'in'
            }),
            contextSubVM = catarse.filtersVM({
                user_id: 'eq',
                status: 'in'
            });

        models.userSubscription.pageSize(9);
github catarse / catarse.js / legacy / src / c / admin-sub-project.js View on Github external
controller: function(args) {
        const project = m.prop({});
        projectVM.fetchProject(args.item.project_external_id, false).then((data) => {
            project(_.first(data));
        });
        return {
            project
        };
    },
github catarse / catarse.js / legacy / src / c / payment-form.js View on Github external
controller: function(args) {
        const isSlip = m.prop(false),
            scope = () => args.vm.isInternational()
                       ? I18nIntScope()
                       : I18nScope();
        return {
            isSlip,
            scope,
            vm: args.vm
        };
    },
    view: function(ctrl, args) {
github catarse / catarse.js / legacy / src / root / survey-create.js View on Github external
id: 'eq'
            }),
            filterVM = catarse.filtersVM({
                project_id: 'eq'
            }),
            {
                project_id,
                reward_id
            } = args;

        rewardFilterVM.id(reward_id);
        filterVM.project_id(project_id);
        const rewardVM = catarse.loaderWithToken(models.rewardDetail.getPageOptions(rewardFilterVM.parameters())),
            l = loader(models.projectDetail.getRowOptions(filterVM.parameters()));

        const reward = m.prop([]);
        l.load().then(projectDetails);
        rewardVM.load().then(reward);

        const choice = {
            multiple: [
                m('span.fa.fa-dot-circle-o'),
                '  MĂșltipla escolha'
            ],
            open: [
                m('span.fa.fa-align-left'),
                '  Resposta aberta'
            ]
        };

        const setQuestionType = (question, type) => () => {
            question.type = type;